I always do the updates with the following three commands:
Although <apt-get autoremove> is supposed to remove old kernels, for some reason it didn't work that way on my system and old kernels kept piling up, all the way back to v3.13.0-24.Code:sudo apt-get update sudo apt-get dist-upgrade sudo apt-get autoremove
As I wanted to have only the latest two kernels present I ran the following two commands.
1) Show all installed packages with a name that starts with "linux-" and contains a number:
2) Specify the names of all unwanted packages and purge them:Code:dpkg -l linux-* | awk '/^ii/{ print $2 }' | grep -e [0-9]
Here is the result:Code:sudo apt-get -y purge linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic linux-headers-3.13.0-29 linux-headers-3.13.0-29-generic linux-image-3.13.0-24-generic linux-image-3.13.0-29-generic linux-image-extra-3.13.0-24-generic linux-image-extra-3.13.0-29-generic
http://i.imgur.com/fS6RrpO.png
I'm wondering if this is a correct method and if I didn't miss anything. The last line on the screenshot (linux-libc-dev:amd64) doesn't belong to a kernel package and must be ignored. As a Linux newbie I wanted to play safe, that's why I decided to enter all kernel names manually on the command line.
There are much more advanced commands available on the web, like the one below, which apparently removes all kernel packages except for the latest one (http://ubuntugenius.wordpress.com/20...s-and-modules/) :
Following blindly a command like that without understanding what all its parts are actually doing might be a bit risky. I'm aware that you can also delete kernels using Ubuntu Tweak or Synaptic (not a very practical option).Code: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



Adv Reply






Bookmarks