How to remove useless Linux kernel in Ubuntu

PHPz
Release: 2023-05-14 21:13:17
forward
2016 people have browsed it

Find useless mirrors

First of all, you can check the currently used kernel, you can get the information through the command: uname -a a . For example, it shows on my desktop For:

Copy the code

The code is as follows:

magc @ magc-desktop : ~ $ uname-a

Linux magc-desktop 2 . 6 . 24 -19-RT # 1 SMP prempt RT Thu August 21, 02:08336003 UTC 2008 i686 GNU/Linux

Then decide which ones need to be removed by looking at the list of all kernels on this machine:

Run command:

Copy code

The code is as follows:

dpkg - get-selections|grep linux

For example, my machine displays:

Copy code

The code is as follows:

magc @ magc-desktop : ~ $ dpkg-get-selections | grep Linux

libselinux1 installation

Linux-Universal Installation

linux-headers-2.6.24-19 Installation

Linux-headers-2.6.24-19-Universal Installation

linux -headers-2.6.24-19-rt installation

linux-headers-2.6.24-21 installation

Linux-headers-2 . 6 . 24-21-universal installation

linux-headers-2.6.24-21-rt installation

Linux-headers-generic installation

linux-headers-rt installation

Linux-image-2 . 6 . 24-19-Universal Uninstall

linux-image-2.6.24-19-rt Installation

Linux-image-2 . 6 . 24-21-Universal Installation

Linux-Image-Universal Installation

linux-image-rt Installation

Linux-Restricted-Module-2.6.24-19-Universal Uninstallation

Linux-restricted-module-2.6.24-19-rt installation

Linux-restricted-module-2.6.24-21-Universal installation

Linux-restricted-module -Common Installation

Linux-Restricted-Module-Common Installation

Linux-Restricted-Module-rt Installation

linux-rt Installation

Linux - Sound-based installation

Linux-Ubuntu-modules-2.6.24-19-Universal Uninstall

Linux-Ubuntu-modules-2.6.24-19-rt Installation

Linux-Ubuntu-module-2.6.24-21-Universal installation

util-linux installation

util-linux-locales installation

where The image is a kernel file, so you can see that there are five kernel versions on my machine. I am currently using 2.6.24-19-rt, so I decided to remove other useless kernels.

How to clean the old kernel image

Before deleting the old kernel, please remember that it is best to keep the two latest kernels (the latest and the previous version) to Prevent the main version from being wrong. Now let's see how to clean old kernel on Ubuntu.

The Ubuntu kernel image contains the following packages.

Linux-image-:kernel image

linux-image-extra-:additional kernel module

Linux-header-:kernel header file

First, check the kernel image installed in the system.

Copy code

The code is as follows:

$ dpkg - list | grep linux-image

$ dpkg -list | grep Linux-title

Among the listed kernel images, you can remove specific versions (such as 3.19.0-15).

Copy code

The code is as follows:

$ sudo apt-get purge Linux-image-3 . 19 . 0-15

$ sudo apt- get purge Linux-headers-3 . 19 . 0-15

The above command deletes the kernel image and its related kernel modules and header files.

Please note that if you have not upgraded your kernel, deleting the old kernel will automatically trigger the installation of the new kernel. In this way, after deleting the old kernel, the GRUB configuration will be automatically upgraded and the relevant GRUB entries in the GRUB menu will be deleted.

If there are many useless cores, you can use shell expressions to delete multiple cores at once. Note that this bracket expression only works in bash or a compatible shell.

Copy code

The code is as follows:

$ 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 face command will delete 4 kernel images: 3.19.0-18 , 3.19.0-20, 3.19.0-21, 3.19.0-25.

If for any reason the GRUB configuration is not upgraded correctly after removing the old kernel, you can try to manually update the configuration using the update-grub2 command.

Copy code

The code is as follows:

$ sudo update-grub2

The above is the detailed content of How to remove useless Linux kernel in Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!