If you have upgraded your kernel you will have found that Ubuntu keeps the older ones around, which can be handy if something breaks in the newer kernel and you have to boot from your old system. Over time, however, these can add up in terms of the amount of space consumed – at around 150MB per kernel you could easily find yourself with over a GB of old kernels if you’ve upgraded enough times. In this example the system we are using is Ubuntu 18.104.22.168. If you’re using Ubuntu Desktop, open up a terminal window – if you’re using Ubuntu Server, log in as usual and run:
to see which kernel you are currently running. Make sure not to delete this one.
Now, to see a list of the installed kernels, we run:
dpkg –list | grep linux-image
This command lists the installed packages and filters the list to include only those which have “linux-image” in them, which should only be your kernels. Your list should look something along the lines of:
ii linux-image-2.6.32-33-server 2.6.32-33.72 Linux kernel image for version 2.6.32 on x86_64
ii linux-image-3.2.0-35-generic 3.2.0-35.55 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-3.2.0-38-generic 3.2.0-38.61 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-server 22.214.171.124.46 Linux kernel image on Server Equipment.
To remove a kernel, run the following:
sudo apt-get purge [kernel]
Using the above list, say we want to get rid of 3.2.0-35. In that case the command would be:
sudo apt-get purge linux-image-3.2.0-35-generic
Once you have removed your unwanted kernels run:
This will update the boot menu accordingly.