[Ubuntu system kernel update and uninstallation]

1 Introduction

When we build the environment, we often encounter the problem that the kernel version does not match, and we need to install a new kernel version; sometimes we encounter an error when installing the software that the boot space is full and cannot be installed. At this time, we need to delete the redundant kernel. Here is a brief introduction to the installation and uninstallation methods of the Ubuntu system kernel.

2. Kernel installation

2.1 System update

To search for an installable kernel version, use the command:

apt-cache  search linux|grep linux-image

Select the required kernel version to install. To install the kernel, you need to install image and header, for example:

apt-get install linux-image-4.4.0-58-generic linux-headers-4.4.0-58-generic

Restart, press ESC to enter the selection menu, select advanced options, select the required kernel version to start the system

2.2 Official website download

Upgrading the Linux Kernel Using dpkg (Manually)

This method helps you to manually download the latest Linux kernel available from the kernel.ubuntu.com website. This method can be useful for you if you plan to install the latest version (rather than the stable or official release). Download the Linux kernel version from the link above.
First check the currently used kernel version:

uname -a

insert image description here
Then choose the latest download according to your own version.
insert image description hereGeneral computer download amd64
insert image description here

Change to the directory where the file is located in the terminal, then execute this command to manually install the kernel:

sudo dpkg --install *.deb

3. Kernel offload

3.1 Demand Analysis

Sometimes we mistakenly install other kernels to affect the user experience. At this time, we can restore the previous lower version kernel. Or when we install the software, if the boot space is full, the system will report an error:

stdout: No space left on device
mkinitramfs failure cpio 141 gzip 1

If you use the following command to view the boot space under the main directory, you can find that the boot space is full, and you need to uninstall the redundant kernel.

df -h

insert image description here

3.2 Uninstall method

First check the currently used kernel version:

uname -a

The kernel in use cannot be deleted, we can delete other kernels

Query the kernel version currently in the system:

dpkg --get-selections | grep linux-image

Unload redundant cores that are not currently in use with the following command:

sudo apt-get purge \
linux-headers-5.19.17-051917 \
linux-image-unsigned-5.19.17-051917-generic \
linux-modules-5.19.17-051917-generic

At this time, check the kernel that exists in the current system:

dpkg --get-selections | grep linux-image

You will find that the uninstalled kernel becomes deinstall,

But this time has not been completely deleted, use the command:

sudo dpkg -P linux-image-5.19.17-051917-generic 

insert image description here

Then use the query command, you will find that the rest of the kernel has been completely deleted, and the boot space has also been released.

References: Ubuntu system kernel installation and uninstallation

Guess you like

Origin blog.csdn.net/vor234/article/details/130970130