Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've got 200 MB assigned for the /boot partition. Everytime I try to update the kernel I get an error message that basically says the size of /boot is full.

What can I do to cleanup /boot and remote/backup the older kernels?

share|improve this question

3 Answers 3

up vote 47 down vote accepted

Graphical method:

You can use Ubuntu Tweak, it's an easy-to-use graphical tool that let you tweak ubuntu, and also, into the "Janitor" section you can clean the system, as well as remove older kernels. You can take it from here: http://ubuntu-tweak.com/

Command line method:

First check your kernel version, so you won't delete the in-use kernel image, running:

uname -r

Now run this command for a list of installed kernels:

sudo dpkg --list 'linux-image*'

and delete the kernels you don't want/need anymore by running this:

sudo apt-get remove linux-image-VERSION

Replace VERSION with the version of the kernel you want to remove.

When you're done removing the older kernels, you can run this to remove ever packages you won't need anymore:

sudo apt-get autoremove

And finally you can run this to update grub kernel list:

sudo update-grub
share|improve this answer
the command line worked like a charm, thanks! –  koba101 Sep 15 '13 at 15:04
sudo dpkg --list 'linux-image*' | grep ^ii makes it a little easier to see just the installed kernels. Also I think the update-grub is harmless but not strictly necessary, that is run automatically when you uninstall a kernel. –  Nelson Mar 5 '14 at 16:15
Use sudo dpkg --list 'linux-image*' | grep ^ii | awk '{print $2}' | sort | egrep "[0-9]-generic" | head -n -3 | tr '\n' ' '; echo "" to get the list of package names to be used with sudo apt-get remove. head -n -3 is used to keep 3 most recent kernels left in the system. –  Sithsu Nov 16 '14 at 6:31
my simple one liner: apt-get remove `dpkg --list 'linux-image*' |grep ^ii | awk '{print $2}'\ | grep -v \`uname -r\`` –  gcb Mar 1 at 20:49

NOTE: this is only if you can't use apt to clean up due to a 100% full /boot

If apt-get isn't functioning because your /boot is at 100%, you'll need to clean out /boot first. This likely has caught a kernel upgrade in a partial install which means apt has pretty much froze up entirely and will keep telling you to run apt-get -f install even though that command keeps failing.

Get the list of kernel images and determine what you can do without sudo dpkg --list 'linux-image*' The one current running kernel versiot can be found with uname -r. Note the two newest versions in the list and the one in use.

Craft a command to delete all files in /boot for kernels that don't matter to you using brace expansion to keep you sane. Remember to exclude the current and two newest kernel images. Example: sudo rm -rf /boot/*-3.2.0-{23,45,49,51,52,53,54,55}-*.

sudo apt-get -f install to clean up what's making apt grumpy about a partial install.

If you run into an error that includes a line like "Internal Error: Could not find image (/boot/vmlinuz-3.2.0-56-generic)", then run the command sudo apt-get purge linux-image-3.2.0-56-generic (with your appropriate version).

Finally, sudo apt-get autoremove to clear out the old kernel image packages that have been orphaned by the manual boot clean.

Suggestion, run sudo apt-get update and sudo apt-get upgrade to take care of any upgrades that may have backed up while waiting for you to discover the full /boot partition.

Suggestion2, Review https://help.ubuntu.com/community/AutomaticSecurityUpdates and consider setting Unattended-Upgrade::Remove-Unused-Dependencies to true in /etc/apt/apt.conf.d/50unattended-upgrades. This will be the equivalent of running autoremove after each security updates to be sure you clean out unused kernels but will also remove other things it thinks are unused saving you from this problem in the future.

share|improve this answer
May I ask why to exclude the last two newest kernel images? –  nightire Apr 22 '14 at 2:37
This way I have the latest for the next reboot and then the one before just in case something breaks in that one. Usually I have plenty of room so it doesn't hurt to have a few and it satisfies my paranoia for not having enough backup options in any given scenario. –  flickerfly Apr 22 '14 at 6:32

This one-liner from http://ubuntuforums.org/showthread.php?t=1435818 did the trick for me

dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic" |while read n;do apt-get -y remove $n;done

However, this only worked once! The second time I ran it, my computer no longer had a kernel (see comment below). Be careful with this command as I spent about 10 hours figuring out what happened and then replacing the kernel.

share|improve this answer
This will remove the current linux-image-extra and the version-less linux-image-server. I would suggest using dpkg --get-selections | grep 'linux-image.*-[0-9].*' | awk '{print $1}' | egrep -v "$(uname -r)" look at the list carefully and only then append | while read n; do apt-get -y remove $n; done –  canaaerus Aug 3 '14 at 10:29
Thanks for your input, I wish I knew why this only worked once –  Mondain Aug 3 '14 at 16:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.