Boot partition cleaning
When a "Not enough free disk space on /boot" message comes up and a "sudo apt-get autoremove" does nothing, there is another way to fix this issue.
To solve this problem you need to know:
- Which Linux kernel version your machine is running on.
uname -r
- Which Linux kernels are installed on your machine.
dpkg -l linux-{image-*,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | sort | grep -e '[0-9]'
This command will list all unused kernels installed on your system. Make sure your current kernel isn't on that list:
dpkg -l linux-{image-*,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]'
Before you continue...If your kernel machine has been recently upgraded, please reboot your machine to check if your system is working fine with that new kernel.
To uninstall and delete the old kernels you just have to pipe the unused kernel list to: sudo apt-get -y purge
dpkg -l linux-{image-*,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge
Depending on how many unused kernels you are asking to remove, this proccess will take several minutes.
Finally, when it's done, reboot your system. You won't see a "Not enough free disk space on /boot" message anymore.