Out of Disk / Media Space When Free Space Still Exists - Linux-Headers and Kernels Clean-up

Mindwatering Incorporated

Author: Tripp W Black

Created: 06/21/2013 at 04:53 PM

 

Category:
Ubuntu
Disk

Issue:
You try to use apt-get to upgrade or install something. Part way through it tells you that the media is full.
A df command returns that 40% of the drive is still empty.

Solution:
If you run df with the INode view, you will see you are out of INodes.
$ sudo df -hTi

I tried telling apt-get to autoremove.
$ sudo apt-get autoremove
However, it repeatedly got stuck on the update that was in process when it died (linux-headers - which use lots of INodes each).

I then tried a super one-liner to remove them:
$ sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
This command still failed because of the "stuck" linux headers.

I then tried a simple aptitude command:
$ sudo aptitude purge
This command wanted to repair the "bad" linux-headers package, and remove several of the older ones. I answered Y to proceed, and it worked. 20% of my INodes were free afterwards.

I then took the opportunity to clean up the kernels. To do this, you should do 3 things:
1. Check your release, and get the list of kernels installed.
2. Purge the kernel(s) desired. (which runs update-grub).
3. Run update-grub2 to confirm the kernel list is correct in grub.

Part #1:
$ sudo uname-r
$ sudo dpkg --list | grep linux-image
(I take a screen grab.)

Part #2:
$ sudo apt-get purge linux-image-2.6.32-26-generic-pae
(Update the line above for your specific kernel(s) to remove.)

Part #3:
$ sudo update-grub2

More good news, after leaving the current kernel and the one previous, a re-run of the df command w/INodes, now shows a little more saves to 23% free.



If requested, run disk check with:
$ sudo fsck /dev/sda1




previous page

×