In the first step, we should first download the kernel software package. You can click to download.
The second step is to unzip the software package corresponding to the linux* version to the current directory. The current directory where I am located is the user's home directory.
tar xvf linux-4.12.tar.xz
The third step cd to switch to the decompressed directory, such as cd linux-4.12, and subsequent compilation and installation operations can only be performed in this directory
The fourth step is to copy the system itself Kernel module function text configuration file and rename it to .config
cp /boot/config-$(uname -r) .config
The fifth step is to install the development package group
yum -y groupinstall "Development Tools"
The sixth step is to perform compilation and use the menu to configure the kernel options. If an error is reported during compilation, follow the The error message prompts you to install the corresponding software package
make menuconfig
The seventh step is to compile the kernel. The compilation process is a bit long. Please wait patiently and do not terminate the operation.
make -j 2 使用2个CPU多线程同时编译
The eighth step is to install the software package according to the error prompt. As shown below
prompts to install openssl-devel software package
yum -y install openssl-devel 根据错误提示安装相应的软件开发包
Step 9 and then continue to compile make -j 2
Step 10 After the compilation is completed, update the database, and then you can check whether the module we compiled into the kernel was successful
updatedb 更新数据库 locate ntfs.ko 查看我们编译进内核的ntfs模块是否存在于内核中
The eleventh step is to install and copy the module file. The installation process is a bit long, please wait patiently
make modules_install
Step 12 Copy the kernel to the /boot directory and modify the grub file. Make will report an error when executing. If an error is reported, install the corresponding software package according to the prompts
make install 将内核拷贝到/boot目录下并修改grub文件 报错信息如下
yum -y install elfutils-libelf-devel 安装elfutils-libelf-devel包 make install 继续执行
Step 13 Check whether the vmlinuz-4.12.0-danran kernel file and grub.cfg or grub.conf files have been changed in the /boot directory
/boot/vmlinuz-4.12.0-danran cat /boot/grub2/grub.cfg 查看grub配置文件,里面多了一个新内核菜单
Step 14 Reboot the system and select the new kernel to start
cd linux-4.12 make clean:清理大多数编译生成的文件,但会保留config文件等; make mrproper:清理所有编译生成的文件、config及某些备份文件 make distclen:mrproper、patches以及编辑器备份文件
Download the corresponding software package for linux*
tar xvf linux-4.12.tar.xz Unzip the kernel to the current directory
cd linux-4.12
cp /boot/config-3.10.0-514.el7.x86_6 .config Copy the system's own functional configuration file to the kernel decompression directory and name it .config
ls .config
yum -y groupinstall "Development Tools" Install Development Tools development package group
make menuconfig Open the graphical function configuration interface
#If an error is reported in the previous step, follow the error prompts to install the corresponding software package, eg ncurses-devel software package
Modify the kernel version number to danran
As shown in the picture above, it prompts to install the openssl-devel software package
.ko" View all ko module files in the newly compiled kernel
make install Copy the kernel to the /boot directory and modify the grub file. Make will report an error when executing. Install the corresponding software package according to the prompts
yum -y install elfutils-libelf-devel Install elfutils-libelf-devel package
ll /boot/vmlinuz-4.12.0-danran View the files in the /boot directory Generate vmlinuz-4.12.0-danran kernel file
cat /boot/grub2/grub.cfg Check the grub configuration file, there is a new kernel menu
#reboot Reboot the system and select the new kernel to start
ls linux-4.12/fs/ntfs/ntfs.ko Check whether the ntfs module is installed
cd linux-4.12 Enter the kernel directory
make fs/ntfs/ntfs.ko Recompile the ntfs.ko module file
ll fs/ntfs/ntfs.ko Check whether the ntfs.ko module file is compiled and generated
cp fs/ntfs/ntfs.ko /lib/modules Copy module files individually to /lib/modules
Kernel related knowledge Please click the link
The above is the detailed content of Kernel compilation steps. For more information, please follow other related articles on the PHP Chinese website!