Linux kernel compilation

  

Compiled linux kernel has been 3 times, each compilation needs to go online to find the compilation steps, I feel that the various information on the Internet is messy, not all suitable for ubuntu12.04 system, so do one recording.

Adaptation version: ubuntu12.04

1. First download the required Linux kernel source code, you can go to kernel.org to download the kernel source code you want.

2. After the download is complete, decompress it. The general kernel code is located under the /usr/src directory, so you can extract your kernel source code to this directory.

3. After the decompression is complete, you can see the directory of the Linux kernel source code.

4. Enter the directory of the kernel source code, execute the command:

make menuconfig Note: This command needs to be executed under the superuser authority, otherwise some inexplicable may be reported. error. After executing this command, you can see the following picture: 


Some of the options in this interface are used to configure the Linux kernel at compile time. We can do it as needed. Choose a configuration.

5. After the configuration is complete, select Exit to exit and save the configuration.

6. Next execute the command:

make all -j4 can compile the kernel, make all is to compile the kernel and the module together. The latter parameter -j4 indicates that the cpu needs to open four threads to compile the kernel. In general, each cpu can open two threads to compile the kernel. My computer has two CPUs, so 4 threads are enabled. This compilation is really fast, I used to compile a thread, and I was speechless. 

7. After the compilation is complete, you can install the kernel. We will copy the arch/x86_64/boot/bzImage in the source directory to /boot/, because the source code version I downloaded is linux-2.6. 30.3, so the command to copy is:

cp arch/x86_64/boot/bzImage /boot/vmlinuz-2.6.30-3 Readers need to use their own cpu type, such as x86 architecture or amd, or 32-bit Or 64-bit, look for bzImage in the appropriate directory. 

8. Copy the System.map in the source directory to the /boot directory:

cp /usr/src/linux-2.6.30.3/System.map System.map-2.6.30- 39. Copy the .config in the source directory to the /boot/directory: 
 cp .config /boot/config-2.6.30-310. Install the module: 
make modules_install11. Switch to /boot/grub /directory: 
cd /boot/grub/12. Update the grub.cfg file: 
 After update-grub2, you can restart the computer. In the previous version, you can start the newly compiled kernel.
Copyright © Windows knowledge All Rights Reserved