Ubuntu – Is it safe to remove old kernels after installing the latest mainline

kerneluninstall

I have installed the mainline kernel 3.10 as recommended here so that I can have my WiFi.

I'm running into space problems as described here (dpkg configuration running out of space, having separate /boot)

Is it safe to run the recommended command described in this blog as pointed out in that answer? If not, how should it be modified? I'm using:

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

dpkg --list | grep linux-image

ii  linux-image-3.10.1-031001-generic         3.10.1-031001.201307131550           amd64        Linux kernel image for version 3.10.1 on 64 bit x86 SMP
ii  linux-image-3.8.0-19-generic              3.8.0-19.30                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-26-generic              3.8.0-26.38                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-27-generic              3.8.0-27.40                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-29-generic              3.8.0-29.42                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-extra-3.8.0-19-generic        3.8.0-19.30                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-extra-3.8.0-26-generic        3.8.0-26.38                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-extra-3.8.0-27-generic        3.8.0-27.40                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
iF  linux-image-extra-3.8.0-29-generic        3.8.0-29.42                          amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
iU  linux-image-generic                       3.8.0.29.47                          amd64        Generic Linux kernel image

I'm not sure about which ones are the latest. Please show me which ones are definitely the oldest and unneeded so they can be removed with sudo apt-get purge linux-image-x.x.x.x-generic.

Best Answer

Yes it's safe to remove kernels you don't use. However I would check this question first for other recommended ways to remove old kernels: