How to free space if /boot partition is full in ubuntu

Today we faced the issue of /boot partition being full on ubuntu server. Some updates were run because of which new kernel version was installed on the server. As /boot partition was only 200 MB in size it was full due to the new kernel images size and files. As there was 5 to 6 unused kernels it was consuming the unnecessary space on the server boot partition. Below are the steps you can use to clean unused kernels from the server

1. Check current running kernel version

uname -r

It will display the version of kernel running

3.19.0-64-generic

2. List the old unused kernels on the server

sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`

Above command will display all the unused kernels on the server it will output below kernels list

linux-image-3.19.0-25-generic
linux-image-3.19.0-56-generic
linux-image-3.19.0-58-generic
linux-image-3.19.0-59-generic
linux-image-3.19.0-61-generic
linux-image-3.19.0-65-generic
linux-image-extra-3.19.0-25-generic
linux-image-extra-3.19.0-56-generic
linux-image-extra-3.19.0-58-generic
linux-image-extra-3.19.0-59-generic
linux-image-extra-3.19.0-61-generic

3. You can now use purge command to remove those old kernels from the server now

$ sudo apt-get purge linux-image-3.19.0-25-generic
$ sudo apt-get purge linux-image-3.19.0-56-generic
$ sudo apt-get purge linux-image-3.19.0-58-generic
$ sudo apt-get purge linux-image-3.19.0-59-generic
$ sudo apt-get purge linux-image-3.19.0-61-generic
$ sudo apt-get purge linux-image-3.19.0-65-generic

4. After removing old kernel version there are also some unused kernel header and devel files you can remove them using apt-get autoremove command

sudo apt-get autoremove

5. Run update grub kernel command to update kernel

sudo update-grub

Grub was updated and now I have enough free space in boot partition.

Leave a Reply