Programster's Blog

Tutorials focusing on Linux, programming, and open source

Ubuntu - Cleaning up /boot

If you have run out of space in /boot and running the command below doesn't appear to be helping:

sudo apt-get autoremove

Then you may need to manually remove some of the old kernels.

Steps

Find out the kernel you are running right now:

uname -r

Make note of this as you must not remove this kernel in the steps below whilst you are using it.

List the images in /boot with ls /boot. You should get output similar to:

abi-3.19.0-33-generic         memtest86+.bin
config-3.19.0-33-generic      memtest86+.elf
grub                          memtest86+_multiboot.bin
initrd.img-3.19.0-33-generic  System.map-3.19.0-33-generic
lost+found                    vmlinuz-3.19.0-33-generic

Append the numbers of the kernels you don't want to the command below:

sudo apt-get remove linux-image-

E.g. if you see vmlinuz-3.19.0-33-generic and you want to remove it you would execute:

sudo apt-get remove linux-image-3.19.0-33-generic

Reinstall Latest Kernel

In case your last update failed because /boot was filled, you will want to reinstall the latest kernel and update grub.

Run the command below to get a list of possible kernels:

sudo apt-get install linux-image

Now reinstall the one you want, for example:

sudo apt-get install --reinstall \
linux-image-3.19.0-33-generic

lastly update grub

sudo update-grub