Environment:
Computer operating system: ubuntu10.04.
linux kernel version: linux-3.12.6
Specific steps:
1. Open the terminal and change to the root user. Enter the command su and then enter the password.
2. Enter the directory where the downloaded kernel is located, and move the downloaded kernel to the /usr/src/ directory
mv linux-3.12.6.tar.xz /usr/src
3. Switch to the /usr/src/ directory, and solve the problem Compressed kernel archive. Since the downloaded compressed package has the .tar.xz suffix, decompression is divided into two steps:
xz -d linux-3.12.6.tar.xz tar -xvf linux-3.12.6.tar
Then do some preparation work, /usr/include/asm, /usr/inlude/linux, /usr/include /scsi is linked to the corresponding directory under the /usr/src/linux/include directory.
The above parts in red are not required.
(Online learning video tutorial sharing: linux video tutorial)
At the same time, clean up the residue in the kernel source code (left behind by multiple compilations):
cd /usr/src/linux-3.12.6 make mrproper
4. Enter cd linux-3.12.6 to enter the decompressed directory.
The following is the kernel configuration.
5. Since there is no graphical interface configuration tool ncurses in the system, first download the tool installation package, then open the directory where the tool is located in the terminal, switch to the root user, and enter the following command:
tar zxvf ncurses-5.9.tar.gz cd ncurses-5.9 ./configure make make install
In this way, ncurses is installed and ready for use.
6. The fifth step is an independent step. Operate alone. This step follows step 4 above. Enter the following command in the terminal:
make menuconfig
The configuration graphical interface appears.
Let’s talk about configuration:
For each configuration option, users have three choices, and their respective meanings are as follows:
< ;*> or [*]——Compile this function into the kernel
[]——Do not compile this function into the kernel
[M]——Compile this function into the kernel Code that is dynamically inserted into the kernel when needed
7. This step is the configuration process. Configure what you need. After the configuration is completed, save and exit.
8. After the configuration is completed, start compiling the kernel and enter the make command in the terminal.
There is also a more troublesome method. Enter the following commands in the terminal in sequence:
make dep make clean make bzlmage make modules
This will also work.
This step takes a long time, please be patient.
Then install the kernel module.
9. Enter the command
make modules_install
10. Enter the command
make install
At this point, the kernel compilation is completed. All that remains is to modify the launcher configuration and run the new kernel program.
11. Copy the generated bzImage file and System.map file to the /boot/ directory. The command is as follows:
cp /usr/src/linux-3.12.6/arch/x86/boot/bzImage /boot/ cp /usr/src/linux-3.12.6/System.map /boot/
12. Enter the command in the terminal:
mkinitramfs 3.12.6 -o /boot/initrd/img-3.12.6
To create the image file, then enter the command:
update-initramfs -c -k 3.12.6
Then enter the command:
update-grub2
Update and modify the system boot configuration.
13. Enter the configuration file of the boot loader. For different boot programs (LILO and GRUB), the paths of the configuration files are different.
For LILO, the path is:/etc/lilo.conf
For GRUB, the path is:/boot/grub/grub.cfg
This system is GRUB boot. So enter /boot/grub/grub.cfg, the command is as follows:
cd /boot/grub gedit grub.cfg
See the following content in the configuration file:
It means that the kernel has been added to Startup item.
14. At this point, the kernel compilation is complete and you can restart the computer.
15. The above is the whole process of compiling the kernel under ubuntu.
Recommended related articles and tutorials: linux tutorial
The above is the detailed content of How to compile the linux kernel. For more information, please follow other related articles on the PHP Chinese website!