picto_welcome.png  Welcome   

picto_download.png  Get Lubuntu   

picto_help.png  Documentation   

picto_contact.png  Get Help   


Over time, the start up list (GRUB) will become longer as new kernels are added. Never remove your current kernel, else your computer will not boot up. It is also generally advised to keep the most recent, previous version in case you start to have problems.

As you are going to be issuing commands with root access, please do read RootSudo.

Manual

Get current kernel version

Start an LXTerminal session enter:

uname -r

This will report back something along the lines of 2.6.32-24-generic This is your current kernel, as you are advised to keep the most recent previous version, you will also want to keep 2.6.32-23-generic (The last digits are incremented on each release).

Remove old kernels

From your LXTerminal session enter:

dpkg -l | grep linux-image-

This will show the installed kernels. Each will have the 2.6.xx-yy numbers in them. For this tutorial I am going to assume that your system has 2.6.32-24-generic, 2.6.32-23-generic, 2.6.32-22-generic and 2.6.32-21-generic. (Obviously your system will be different). As you need to keep the current one (2.6.32-24-generic) and the most recent previous one (2.6.32-23-generic), you can remove 2.6.32-22-generic and 2.6.32-21-generic

sudo apt-get autoremove linux-image-2.6.32-22-generic linux-image-2.6.32-21-generic

You will save approximately 120Mb per kernel. The 'autoremove' based command simply removes the old kernel modules. Grub will automatically be updated to show these changes so will give fewer options when you see your Grub menu

You can now close the terminal session. Next time you start your computer the older entries will no longer be there.

Automatic

Advanced users

Now that we've learned how to do it manually, here we'll post a command that will automatically purge all the unused kernels. Please note that with this command even the most recent previous version will be removed.

Warning /!\ This is only recommended for users that know what they are doing as only the most recent version remains Warning /!\

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

Problems

If you got a bit carried away and deleted all the kernels, you fall into the "You did WHAT?!?!" class. You will be pleased to know that you are not the first, nor will be the last, person to do this. Get your LiveCD and head over to GRUB reports no operating system.

Lubuntu/Documentation/RemoveOldKernels (last edited 2012-03-05 21:13:51 by chrisdruif)