Originally posted here:http://www.go2linux.org/clean-linux-...ages-grub-menu by Deven
Just too damn good not to share. Especially seeing as how when I attempted to manually remove the old kernels I ended up spending a few hours getting a kernel back on after deleting all of them.
save as cleanKernels.sh
ls /boot/ | grep vmlinuz | sed 's@vmlinuz-@linux-image-@g' | grep -v `uname -r` > /tmp/kernelList
for I in `cat /tmp/kernelList`
aptitude remove $I
rm -f /tmp/kernelList
update-grub #not sure if needed
Execute as root or chmod 755 it.
Yippee you just freed up some disk space!
sudo bash cleanKernels.sh