My /boot
partition is nearly full and I get a warning every time I reboot my system. I already deleted old kernel packages (linux-headers...), actually I did that to install a newer kernel version that came with the automatic updates.
After installing that new version, the partition is nearly full again. So what else can I delete? Are there some other files associated to the old kernel images?
Here is a list of files that are on my /boot
partition:
:~$ ls /boot/
abi-2.6.31-21-generic lost+found
abi-2.6.32-25-generic memtest86+.bin
abi-2.6.38-10-generic memtest86+_multiboot.bin
abi-2.6.38-11-generic System.map-2.6.31-21-generic
abi-2.6.38-12-generic System.map-2.6.32-25-generic
abi-2.6.38-8-generic System.map-2.6.38-10-generic
abi-3.0.0-12-generic System.map-2.6.38-11-generic
abi-3.0.0-13-generic System.map-2.6.38-12-generic
abi-3.0.0-14-generic System.map-2.6.38-8-generic
boot System.map-3.0.0-12-generic
config-2.6.31-21-generic System.map-3.0.0-13-generic
config-2.6.32-25-generic System.map-3.0.0-14-generic
config-2.6.38-10-generic vmcoreinfo-2.6.31-21-generic
config-2.6.38-11-generic vmcoreinfo-2.6.32-25-generic
config-2.6.38-12-generic vmcoreinfo-2.6.38-10-generic
config-2.6.38-8-generic vmcoreinfo-2.6.38-11-generic
config-3.0.0-12-generic vmcoreinfo-2.6.38-12-generic
config-3.0.0-13-generic vmcoreinfo-2.6.38-8-generic
config-3.0.0-14-generic vmcoreinfo-3.0.0-12-generic
extlinux vmcoreinfo-3.0.0-13-generic
grub vmcoreinfo-3.0.0-14-generic
initrd.img-2.6.31-21-generic vmlinuz-2.6.31-21-generic
initrd.img-2.6.32-25-generic vmlinuz-2.6.32-25-generic
initrd.img-2.6.38-10-generic vmlinuz-2.6.38-10-generic
initrd.img-2.6.38-11-generic vmlinuz-2.6.38-11-generic
initrd.img-2.6.38-12-generic vmlinuz-2.6.38-12-generic
initrd.img-2.6.38-8-generic vmlinuz-2.6.38-8-generic
initrd.img-3.0.0-12-generic vmlinuz-3.0.0-12-generic
initrd.img-3.0.0-13-generic vmlinuz-3.0.0-13-generic
initrd.img-3.0.0-14-generic vmlinuz-3.0.0-14-generic
Currently, I'm using the 3.0.0-14-generic
kernel.
You've a lot unused kernels. Remove all but the last kernels with:
This is shorthand for:
Removing the
linux-image-x.x.x-x
package will also removelinux-image-x.x.x-x-generic
.The headers are installed into
/usr/src
and are used when building out-tree kernel modules (like the proprietary nvidia driver and virtualbox). Most users should remove these header packages if the matching kernel package (linux-image-*
) is not installed.To list all installed kernels, run:
One command to show all kernels and headers that can be removed, excluding the current running kernel:
It selects all packages named starting with
linux-headers-<some number>
orlinux-image-<some number>
, prints the package names for installed packages and then excludes the current loaded/running kernel (not necessarily the latest kernel!). This fits in the recommendation of testing a newer kernel before removing older, known-to-work kernels.So, after upgrading kernels and rebooting to test it, you can remove all other kernels with:
Your boot partition is full. Since this is a kernel update, these files will be copied to the boot partition so you need to clean in out. Here is a blog post that will show you how to clear the old kernel images with one command. I'll give a basic synopsis of the method. Use this command to print out the current version of your kernel:
Then use this command to print out all the kernels you have installed that aren't your newest kernel:
Make sure your current kernel isn't on that list. Notice how this is the majority of the final command (down below). To uninstall and delete these old kernels you will want to pipe these arguments to:
Now we can do everything we want by combining these last two commands into this unholy mess:
And that one command will take care of everything for you. I will confirm that this does work perfectly but never trust anybody on the internet. :) For more info, the blog post gives a very good explanation of what each part of the command does so read through it so you are satisfied that it does what you want it to do.
This command is doing the job automatically.
The Synaptic Package Manager can be used to easily select and remove old kernel images.
If you don't already have Synaptic installed:
Start the application and select the options shown.
You should be able to highlight all the "linux-" packages with the version "2.6.x" where x is between 31 to 38 according to the files in your /boot folder.
Right-click each of those linux packages and choose the option "Mark for Complete Removal". Finally click the apply button. This will remove all the files and any associated files. Your
/boot
folder should now be a bit tidier.Thank you for your detailed post of your problem, this got me going in the right direction. Although it is useful to keep previous kernel files you can remove all of them in one go, check this post:
How to Remove All Unused Linux Kernel Headers, Images and Modules
Done via command line. If you are doing this via remote use something like WINSCP to open a terminal session and just paste it in, works very well.
Here it is copied from article link, I suggest you read the full article:
This is a new answer to an old question, but an easy way to clean this thing (and more) is to install Ubuntu Tweak. To install it:
then you can run Ubuntu Tweak, Going to the "janitor" tab, and from here it's a matter of three clicks:
It is better to leave the last kernel (you never know) or a well-known working kernel for safety, though; but that's easily customizable.
You can use the same tool to clean a lot of things --- just remember that if you clean thumbnail cache or TB cache then the system will have to rebuild them if they are needed.
I was able to fix the problem by using
dpkg
to remove the packages directly. Although the packages are still listed indpkg -l
, the files are removed from/boot
, freeing up space.After this,
apt-get -f install
fixed my dependency problems, and all was well with the world.I'll not be accepting this answer of mine, however, as I still need to know if I should be increasing my
/boot
size or doing something else.You can stop using a separate /boot partition, then you won't have such limited space there. To do this, unmount the partition, then mount it somewhere else and copy all of the files there to the /boot directory in your root partition, then remove the entry from /etc/fstab and reinstall grub. For example ( you will need to use the correct partition ):
You can then use gparted to delete the old /boot partition, and possibly extend the root partition to use that space. To extend the root partition you will need to boot from the livecd, and the free space needs to be immediately to the right. If the /boot partition is currently to the left of the root partition, then you will need to first move the root partition to the left, then extend it, but this can take a very, very long time, so may not be worth the trouble.
List all kernels:
Display current kernel:
List all kernels EXCEPT current one:
Make sure your current kernel isn't on that list.
Remove all kernels EXCEPT current one:
Clear other stuff:
If it still gives you boot disk space error for installing/uninstalling files then directly remove one of OLD image from /boot directory,
NOTE: Please review current kernel image again before deleting any image.
If it stills throws any error then repeat following commands to remove unwanted kernels,
Taking the best from the answers above, my tried-and-true approach is this:
uname -a
to find the running kernel.dpkg -l linux-{headers,image}-\* | grep ^ii
to list all currently installed kernel-related packages. This will include the running kernel.sudo apt-get purge linux-{image,headers}-3.16.0-{xx,yy,zz}
to remove the old kernels. Replacexx,yy,zz
with a list of the kernel builds you want to remove—these are all the builds listed by the previous command which are older than the currently running kernel. Make sure you don't remove the currently running kernel—your system will become unbootable. You may also need to change the kernel version from3.16.0
to whatever is installed on your system.sudo apt-get autoremove
—this will remove any leftover dependencies of the old kernels which are no longer needed by the current one, freeing up some more space.You may have header files without matching kernel versions installed, or vice versa—just include all of these versions in the command. APT will complain that some packages can't be removed because they are not installed, but that will do no harm.
If something fails...
sudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}
.linux-image
packages are required by thelinux-headers
packages of the same version (which you also want to uninstall), dpkg may have failed to resolve that. Re-examine the output ofdpkg -l
and specify any package name suffixes on the command line. For example, on one of my systems the command that eventually worked wassudo dpkg --purge linux-{image,headers}-3.16.0-{xx,yy,zz}-generic-pae
.