Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Overtime with Ubuntu updates the GRUB menu lists a lot of previous Linux kernels and eats a lot of hard-disk space. How can the unused kernels be removed easily?

share|improve this question

migrated from Jul 30 '11 at 7:40

This question came from our site for professional and enthusiast programmers.

Try – Paul R Jul 30 '11 at 6:55

Open the Synaptic package manager from the System->Administration menu.

Click the “Search” button on the tool bar and search for linux-image-2.

The results should show every available and installed kernel. A green box on the left indicates that the package is installed. The only linux-image you want installed is the latest one. Find the package corresponding to the kernel to you running currently (this is the kernel you found in the terminal window). Make sure you keep that one. Now you can uninstall the old kernels from the list by clicking their boxes and selecting "Mark for Removal".

Got this from here

share|improve this answer

Open a terminal and run the below command. On reboot, only the latest kernel will be shown in the GRUB menu.

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

Root password is required to run the above command.

Thanks to ubuntugenius.

share|improve this answer

You can use Ubuntu Tweak for that or remove entries in /boot. For example, if I have vmlinuz-2.6.32-23-generic and vmlinuz-2.6.32-22-generic by removing the last one I'll get rid of one entry. Also, there can be a vmlinux instead of vmlinuz. There are also other files with version information too. You can remove them too. Always keep the latest one.

share|improve this answer

The below mentioned solution is Ubuntu specific.

  1. List all the kernel images and headers

    dpkg --list | grep linux-image
    dpkg --list | grep linux-headers
  2. Remove the image and headers of the kernel which you want to remove.

    sudo apt-get purge linux-image-3.19.0-15
    sudo apt-get purge linux-headers-3.19.0-15

    The above commands will remove the kernel image and its associated kernel modules and header files.

  3. After removing the unused kernel, update the GRUB configuration.

    sudo update-grub2
  4. Now reboot and verify if the GRUB menu is been properly cleaned up or not.

share|improve this answer
  1. First check the current kernel version running on your host machine.

    uname -r
  2. List all the kernels installed in the host.

    rpm -qa kernel //Lists all the kernels including the one you want to remove

    Optional: If you want to take the backup of the kernel:

    cp /etc/grub.conf /tmp/grub1.conf
  3. Uninstall the kernel which you want to remove.

    rpm -e –nodeps
  4. Check if it is uninstalled or not.

    rpm -qa kernel
share|improve this answer
This is clearly an Ubuntu-specific question. rpm does not exist on Ubuntu as it uses apt. – Mikey T.K. Feb 18 at 2:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .