Free up Disk Space on /boot

By | March 4, 2015

Occasionally you will need to free up some disk space on the /boot partition after updating your kernel several times.  Here are a few commands to list all installed kernels on your Ubuntu system, except the running one.

kernelver=$(uname -r | sed -r 's/-[a-z]+//')
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver

List all installed kernels:

dpkg -l linux-image-\* | grep ^ii

Then, you can remove the un needed kernels with this command:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

Leave a Reply

Your email address will not be published. Required fields are marked *