My /boot partition hit 100% and now I can't upgrade. Can't remove old kernels to make room
Solution 1:
Freeing Up Space on the Root File System
To free up space on the root file system you can try to execute apt-get clean
.
If that doesn't work you can go to /var/cache/apt/archives
and manually remove a few files from the cache to get some space back, e.g.:
sudo rm linux-headers-*
It won't hurt to remove all of the .deb
files here if you need to - that is what apt-get clean
does. They will be automatically be re-downloaded by apt
if they are needed again.
Freeing Up Space on the /boot File System
The Original Poster has a separate /boot
partition, and that is what is full and preventing the apt
system from working. It will be necessary for him to free up space there.
If there almost enough space, go to /boot
and remove a config file or two:
sudo rm config-3.2.0-19-generic-pae
for example, but using the name of one of the kernel versions you intend to remove anyway. This will free up a little space (about 144K apiece).
If you need more space individually remove old vmlinuz
, initrd
, abi
and System.map
files until you have enough space (about 22M for one of my i386 kernel versions).
Whatever you do, don't remove them all. You should at least keep the latest two matching versions of each kind of file, for each kind of kernel you use.
Then proceed with your apt-get install commands. As mentioned above they may have to re-download some of the debs you deleted, but if so that will happen automatically. When you have apt working again, clean up by using apt-get to remove the packages corresponding to the files you removed - so everything matches.
The config file in /boot
is the kernel config that was used by the kernel team to build the kernel of the same name. It should be harmless to remove unless you want it for reference or to aid you in building your own kernels.
Finally you are manually removing an old kernel package or two from the /boot
partition to make even more room for the new one.
Solution 2:
In my case, the apt
commands and dpkg
command could not finish, and could not remove.
The autoupdate had failed on installing 2.6.32-56-server
.
My first step, was to identify space to be used,
cd /boot
du -sk *|sort -n
I had about 30 kernels and supporting files.
I did a uname -a
to get the running kernel,
I identified that I was on Linux alternate 2.6.32-43-server
and did a tar
of 6 of the versions that were not running, and were old.
tar -cvf ~username/boot.tar *2.6.32-44-server *2.6.32-45-server *2.6.32-46-server *2.6.32-47-server *2.6.32-48-server *2.6.32-49-server
I then did a rm -rf
of what I had backed up:
rm -rf *2.6.32-44-server *2.6.32-45-server *2.6.32-46-server *2.6.32-47-server *2.6.32-48-server *2.6.32-49-server
I am showing these commands as examples, you will have to decide what you will work with for your situation.
Now that I had some space on /boot
, I was able to run
apt-get -f install
To clean up the failed install of 2.6.32-56-server
.
I then did a
apt-get remove linux-headers-2.6.32-38 linux-headers-2.6.32-38-server linux-image-2.6.32-38-server
apt-get remove linux-headers-2.6.32-39 linux-headers-2.6.32-39-server linux-image-2.6.32-39-server
This gave me room to put back what I had backed up.
tar -xf ~username/boot.tar
rm ~username/boot.tar
To clean up, I then could run:
apt-get autoremove
I rebooted and am now down to using 4% of /boot
.
Solution 3:
You can use dpkg
instead of apt-get
to remove older kernels:
sudo dpkg -r linux-image-3.2.0-29-generic
Solution 4:
I noticed there were still some files of the old versions in the boot directory:
$ ls /boot
vmcoreinfo-2.6.31-17-server
And the package manager would list the old versions:
dpkg -l | grep linux-image
I therefore used this command (autoremove
would also remove more recent images I don't want to remove)
sudo apt-get purge linux-image-2.6.31-17-server
I had still some headers left:
dpkg -l | grep linux-headers
So I did this:
sudo apt-get purge linux-headers-2.6.32-34
Finally there was one package left I couldn't remove with apt-get purge:
$ dpkg -l | grep linux-image
rc linux-image-2.6.28-11-server
Source: Remove a package marked as rc by dpkg
sudo dpkg --purge linux-image-2.6.28-11-server
Solution 5:
I found that the only thing that worked for me was using Aptitude.
sudo aptitude
Then when it opens it will usually say something about unmet dependencies on the bottom. You can hit the letter g
to proceed with the suggested removal. It will take you to a page where it lists what is going to happen.
There should be a minus -
next to the broken kernels. Press g
again and it will remove the broken kernels. Press q
to quit. Then you should be able to use sudo apt-get autoremove
to get rid of the old kernels and free up space.