Kernel compilation steps

巴扎黑
Release: 2017-07-21 09:18:42
Original
2168 people have browsed it

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
Copy after login

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
Copy after login

The fifth step is to install the development package group

yum -y groupinstall "Development Tools"
Copy after login

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
Copy after login

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多线程同时编译
Copy after login

The eighth step is to install the software package according to the error prompt. As shown below

Kernel compilation steps
prompts to install openssl-devel software package

yum -y install openssl-devel  根据错误提示安装相应的软件开发包
Copy after login

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模块是否存在于内核中
Copy after login

The eleventh step is to install and copy the module file. The installation process is a bit long, please wait patiently

make modules_install
Copy after login

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文件

报错信息如下
Copy after login

Kernel compilation steps

yum -y install elfutils-libelf-devel  安装elfutils-libelf-devel包
make install  继续执行
Copy after login

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配置文件,里面多了一个新内核菜单
Copy after login

Kernel compilation steps

Step 14 Reboot the system and select the new kernel to start

Clean up the files generated by kernel compilation

cd linux-4.12
make clean:清理大多数编译生成的文件,但会保留config文件等;
make mrproper:清理所有编译生成的文件、config及某些备份文件
make distclen:mrproper、patches以及编辑器备份文件
Copy after login

The kernel compilation operation process is as follows

  1. Download the corresponding software package for linux*

  2. tar xvf linux-4.12.tar.xz Unzip the kernel to the current directory

  3. cd linux-4.12

  4. 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

  5. ls .config

  6. yum -y groupinstall "Development Tools" Install Development Tools development package group

  7. make menuconfig Open the graphical function configuration interface
    Kernel compilation steps

  8. #If an error is reported in the previous step, follow the error prompts to install the corresponding software package, eg ncurses-devel software package

  9. Modify the kernel version number to danran
    Kernel compilation steps
    Kernel compilation steps
    Kernel compilation steps
    Kernel compilation steps

  10. ##Add kernel support for ntfs function


    Kernel compilation steps
    Kernel compilation steps
    Kernel compilation steps

  11. ##vim .config Check the configuration file to confirm whether the ntfs function is enabled and whether the kernel version number has changed
  12. lscpu Check the cpu information and the number of cpu cores
  13. make - j 2 Edit the kernel

  14. Install the corresponding software package according to the compilation error prompt

  15. As shown in the picture above, it prompts to install the openssl-devel software packageKernel compilation steps

  16. yum -y install openssl-devel Install the corresponding software development package according to the error prompt
  17. yum -y install elfutils-libelf-devel

  18. make -j 2 Continue to compile, the compilation time is a bit long, please wait patiently, do not terminate
  19. updatedb Update database
  20. locate ntfs.ko Check whether the ntfs module we compiled into the kernel exists in the kernel

  21. Kernel compilation steps

  22. make modules_install installation Copy module files, please wait patiently for the copying process

  23. Kernel compilation steps

  24. cd /lib/modules
  25. find 4.12.
  26. .danran/ -name "

    .ko" View all ko module files in the newly compiled kernel

  27. cd /root/linux-4.12
  28. 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
    Kernel compilation steps

  29. yum -y install elfutils-libelf-devel Install elfutils-libelf-devel package

  30. ll /boot/vmlinuz-4.12.0-danran View the files in the /boot directory Generate vmlinuz-4.12.0-danran kernel file

  31. cat /boot/grub2/grub.cfg Check the grub configuration file, there is a new kernel menu
    Kernel compilation steps

  32. #reboot Reboot the system and select the new kernel to start

  33. ls linux-4.12/fs/ntfs/ntfs.ko Check whether the ntfs module is installed

Compile the ntfs.ko module file separately

  1. cd linux-4.12 Enter the kernel directory

  2. make fs/ntfs/ntfs.ko Recompile the ntfs.ko module file

  3. ll fs/ntfs/ntfs.ko Check whether the ntfs.ko module file is compiled and generated

  4. cp fs/ntfs/ntfs.ko /lib/modules Copy module files individually to /lib/modules
    Kernel compilation steps

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!

Related labels:
source:php.cn
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