Centos8 compiles and installs the kernel

First download the kernel , the 5.x version of the kernel, download address:
https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/

System installation related packages:

# yum install -y bc gcc make python3 ncurses-devel flex bison openssl-devel elfutils-libelf-devel

unpack the kernel

[root@localhost ~]# tar xvf linux-5.10.60.tar.xz
[root@localhost linux-5.10.60]# cd linux-5.10.60

Use an existing config file

[root@localhost linux-5.10.60]# cp -p /boot/config-4.18.0-305.3.1.el8.x86_64 .config

Use old configuration parameters

[root@localhost linux-5.10.60]# sh -c 'yes ""| make oldconfig'

Make compiles, use the nproc command to use all cpu threads:

[root@localhost linux-5.10.60]# make -j $(nproc)

Make reports an error:

make[1]: *** No rule to make target 'certs/rhel.pem', needed by 'certs/x509_certificate_list'.  Stop.


And this error Failed to generate BTF for vmlinux

Edit the .config configuration file and comment out the following two lines

#CONFIG_SYSTEM_TRUSTED_KEYS="certs/rhel.pem"
#CONFIG_DEBUG_INFO_BTF=y



Then execute make -j $(nproc) again

[root@localhost linux-5.10.60]# make -j $(nproc)


Module installation, copy the compiled module to the system directory

[root@localhost linux-5.10.60]# make modules_install


Install the binary kernel image, generate and install the boot initialization file system image file

[root@localhost linux-5.10.60]# make install


Now you can view the /lib/modules directory under the 5.10.60 kernel directory.

[root@localhost linux-5.10.60]# ll /lib/modules
total 8
drwxr-xr-x. 6 root root 4096 Apr 11 14:38 4.18.0-305.3.1.el8.x86_64
drwxr-xr-x. 3 root root 4096 Apr 11 15:48 5.10.60


Update grub startup items

[root@localhost linux-5.10.60]# grub2-mkconfig -o /boot/grub2/grub.cfg

Check if the default startup item is 5.10.60

[root@localhost linux-5.10.60]# grubby --default-kernel
[root@localhost linux-5.10.60]# grubby --default-index


View all startup items:

[root@localhost linux-5.10.60]# grubby --info=ALL


You can use grubby --set-default to set the default startup items.
After the setting is complete, you can restart the system to check whether you can enter the system.
 

Guess you like

Origin blog.csdn.net/linux_hua130/article/details/130357930