How to remove old kernels that are no longer used on Ubuntu

Source: Internet
Author: User

Questions : I've upgraded several kernels on my Ubuntu in the past. Now I want to delete these old kernel images to save my disk space. How to remove the previous version of the kernel from Ubuntu in the simplest way?

On Ubuntu, there are several ways to upgrade the kernel. In Ubuntu desktop, software updates allow you to check and update to the latest kernel every day. One of the most important security update projects on Ubuntu servers is that the Unattended-upgrades software package updates the kernel automatically. However, you can also manually update them with Apt-get or aptitude commands.

Over time, a persistent kernel update will accumulate a large number of unused cores in the system, wasting your disk space. Each kernel image and its associated module/header files consume 200-400MB disk space, so wasted disk space is rapidly increased by the unused kernel.

The Grub Manager maintains a grub portal for each old kernel in case you want to use them.

As part of Disk Cleanup, if you no longer use these, you can consider cleaning up these images.

How to clean up old kernel mirrors

Before deleting the old kernel, it is best to keep the 2 closest kernels (the latest and previous versions) in case the major version goes wrong. Now let's see how to clean up the old kernel on Ubuntu.

The following packages are included in the Ubuntu kernel image.

linux-image-: Kernel Mirroring

linux-image-extra-: Additional kernel modules

linux-headers-: Kernel header file

First check the kernel image installed in the system.

$ dpkg--list | grep linux-image

$ dpkg--list | grep linux-headers

In the kernel image listed, you can remove a specific version (such as 3.19.0-15).

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

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

The above command removes the kernel image and its associated kernel modules and header files.

Note If you have not upgraded the kernel then deleting the old kernel will automatically trigger the installation of the new kernel. This way, after removing the old kernel, the grub configuration is automatically upgraded to remove the associated grub entry from the Grub menu.

If you have a lot of useless kernels, you can use shell expressions to delete multiple cores at once. Note that this bracket expression is only valid in bash or a compatible shell.

$ sudo apt-get purge linux-image-3.19.0-{18,20,21,25}

$ sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}

The above command removes 4 kernel images: 3.19.0-18, 3.19.0-20, 3.19.0-21, and 3.19.0-25.

If the grub configuration is not properly upgraded after removing the old kernel for any reason, you can try to manually update the configuration with the UPDATE-GRUB2 command.

$ sudo update-grub2

Reboot now to verify that the Grub menu is properly cleaned up.

Free pick up Brother Lian IT Education Original Linux Operations Engineer video/Detailed Linux tutorials, details of the website customer service: http://www.lampbrother.net/linux/

or hooking up with Q2430675018.

Welcome to the Linux Communication Group 478068715


How to remove old kernels that are no longer used on Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.