[ubuntu-uk] Unwanted kernels
Tyler J. Wagner
tyler at tolaris.com
Sat May 4 18:53:21 UTC 2013
On 2013-05-04 16:47, Colin Law wrote:
> On 4 May 2013 15:53, Tony Pursell <ajp at princeswalk.fsnet.co.uk> wrote:
>> Hi All
>>
>> Has anyone got any advice or tips on how to safely rid oneself of unwanted
>> kernel. I thought this was an issue that had been solved but I'm still left
>> with 5 ver 2.6 and 8 ver 3.0 kernels despite having upgraded to Raring. I
>> don't mind keeping the latest 3.8 kernel and the 3.5 before that and the 3.2
>> before that.
>
> I can never remember exactly how to do it, I just google
> ubuntu remove kernels
> and multiple good hits appear. I don't think there is any danger as
> long as you don't remove the current ones.
I use the following to purge all kernels which aren't the current kernel or
the latest kernel by version number.
( \
KERNEL_HIGHEST=$(dpkg -l 'linux-image-[0-9.]*-[0-9]*-[a-zA-Z0-9]*' | grep
^ii | awk '{print $2}' | sort -V | tail -n 1 | sed
's/^linux-image-\([0-9.]*-[0-9]*\)-.*$/\1/') ; \
KERNEL_CURRENT=$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/") ; \
sudo apt-get purge $(dpkg -l 'linux-*-[0-9-]*' | grep ^ii | awk '{print
$2}' | sed "/$KERNEL_CURRENT/d;/$KERNEL_HIGHEST/d" ) ; \
)
The above will list the kernels to be removed and prompt you before proceeding.
Regards,
Tyler
--
"Anyone who truly understands UI design realizes that every preference
option is an admission of defeat: it's there because you couldn't just
get it right the first time."
-- Jamie Zawinski
More information about the ubuntu-uk
mailing list