While performing some regular updates on a few of my Ubuntu VMs, I ran out of space to continue performing updates on the /boot
volume.
The following commands will help you locate and clear up any unused Linux kernels reclaiming space in this volume.
First, run the following to determine what will be removed. This command won't remove anything because of the --dry-run
switch.
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get --dry-run remove
Next, you can go ahead and remove the found files by running the command below:
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get -y purge
Hope this help!