Tips for Remove Legacy Kernel Image for Debian/Ubuntu

After numbers of update to your Debian/Ubuntu installation, usually a lot of legacy kernel image are keep inside your box, so you may hope to remove all of them. Just execute following command (i.e. after aptitude -y full-upgrade && reboot):

dpkg -l 'linux-*' | \
  sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | \
  xargs sudo apt-get -y purge

Reference:

Add new comment