Linux Kernel Compilation

Source: Internet
Author: User

The Linux kernel has been compiled three times. Every time you compile the Linux kernel, you need to go to the Internet to find the compilation steps. I feel that all the information on the Internet is messy, and not all of them are suitable for ubuntu12.04 systems. Therefore, make a record.

Applicable version: ubuntu12.04

1. First download the required Linux kernel source code. You can go to kernel.org to download the desired kernel source code.

2. decompress the downloaded file. Generally, the kernel code is located under the/usr/src directory, so you can decompress your kernel source code to this directory.

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

4. Go to the kernel source code directory and run the following command:

make menuconfig
Note: This command must be executed with the superuser permission. Otherwise, some inexplicable errors may occur. After executing this command, you can see the following picture:

 

Some options in this interface are used to configure the Linux kernel during compilation. we can select the configuration as needed.

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

6. Run the following command:

make all -j4
You can compile the kernel. make all is to compile the kernel and modules together. The following parameter-j4 indicates that the cpu needs to enable four threads to compile the kernel. Generally, each cpu can enable two threads to compile the kernel. My computer has two CPUs, so four threads are enabled. This compilation is really fast. I used to compile a thread, and it was almost speechless.

7. after the compilation is complete, we can install the kernel, We will copy the arch/x86_64/boot/bzImage under the source code directory to/boot/, because the source code version I downloaded is linux-2.6.30.3, therefore, the copied command is:

cp arch/x86_64/boot/bzImage /boot/vmlinuz-2.6.30-3
Readers need to find bzImage in the appropriate directory based on their CPU type, such as x86 architecture or amd, or 32-bit or 64-bit.

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

cp /usr/src/linux-2.6.30.3/System.map System.map-2.6.30-3
9. Copy. config in the source code directory to the/boot/directory:
 cp .config /boot/config-2.6.30-3
10. Installation module:
make modules_install
11. Switch to the/boot/grub/directory:
cd /boot/grub/
12. Update the grub. cfg file:
 update-grub2
Then you can restart your computer and start the New Compiled kernel in previous version.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.