• Edit
  • Delete

Ubuntu remove unused kernels from /boot

http://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu

First print a list of kernels:

  • dpkg --list | grep linux-image

Check if the latest kernels are not in the following list

  • dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p' | head -n -2 | xargs apt-get purge

If ok add "-y" to "apt-get remove" to remove all the unused kernels:

  • dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p' | head -n -2 | xargs apt-get -y purge

Settings for automatic removal

  • vi /etc/apt/apt.conf.d/50unattended-upgrades
    • Unattended-Upgrade::Remove-Unused-Dependencies "true";