Linux Kernel compilation steps (based on ubuntu10.04 + 2.6.35.2 kernel)

Source: Internet
Author: User

It was just a day, and I studied how to compile Linux kernel in my spare time. I used to work on Windows platforms and almost never used Linux, so I wanted to have a good time. The platform is the latest Ubuntu 10.04 LTS, and the kernel is also the latest version 2.6.35.2 downloaded. In fact, kernel compilation is much more convenient than in the past. If menuconfig is used, manual configuration is almost unnecessary, and commands do not need to be typed. Compiling the kernel is the first part of learning Linux kernel.

 

Compilation steps:

 

1. To http://www.kernel.org/
Download the latest kernelSource codeThe linux-2.6.35.2.tar.bz2 (the latest version) is then placed under the/usr/src directory.

 

2. To facilitate the compilation process, we recommend that you enter the root account to perform operations so that you do not need to use the sudo command every time. (I still don't know whether the security is reliable)

Enter terminal and execute:Su Root

 
Enter your password to perform the remaining operations under the root account permission.

 

3. The downloaded Linux source code is a compressed package and needs to be decompressed to the directory:Tar-J
X
VF linux-2.6.35.2.tar.bz2-C/usr/src

 

4. Go to the decompressed directory:CD/usr/src/linux-2.6.35.2

 

5. Check for the correct. o file and dependency:Make mrproper

(In fact, this step can be omitted, because the source code just downloaded must be clean. If compiled code is used, this step is required)

 

6. Configure kernal options:Make menuconfig

(This step is very important. It determines that you can customize your kernel. When you use menuconfig, some options are listed.) The main list is as follows:

 

General setup: General configurations, such as kernel config, CPU group, and aduiting

Loadable module support: customizes the modules to be loaded.

Enable the block layer: mainly set Block devices and large files

Processor type and features: processor configuration and customization

Power Management Options: customization of power management, such as Hibernate

Bus options: PCI bus Customization

Executable file formats: mainly set elf Configuration

Networking Support: custom network options, including wireless, Bluetooth, and network options

Device Drivers: customizes the device drivers you need to load

Fireware drivers: firmware driver settings such as bios and EFI

File System: File System settings, including ext3, ext4, fat, CD/DVD... and so on.

Kernel hacking: mainly set the kernel debugging, which is useful for kernel debugging.

Security Options: Security Options

Cryptographic API: encryption settings, including MD5, sha1, CRC, and so on.AlgorithmConfiguration

Virtualization: virtualization settings

Library Routines: Mainly customizes the CRC verification function.

 

There are 16 items above, and each item has more than N items. To be honest, each item in this project is enough to be studied for a while. However, for Kernel compilation, you can use all the default options (which will prolong the Compilation Time ). After setting menuconfig, save and exit.

 

7. Establish the modules dependency:Make Dep

 

8. The remaining unsuitable files after the configuration is deleted:Make clean

 

9. Compile the kernel:Make bzimage

(It takes some time to view the machine situation and the definition of menuconfig. I use the default setting, and it takes about 20 minutes to compile. If the kernel is less than 512 KB, you can useMake zimage
Command)

 

10. Compile the kernel module:Make modules

(This will take some time, depending on the number of modules you have customized. It takes about 25 minutes to use the default settings. You can useMake-j <n>
Speed up compilation. N indicates the number of your CPUs)

 

11. Install the kernel module:Make modules_install

 

12. Install the kernel:Make install

 

13. Create an initrd file: (1)CD/

(2) input:Mkinitramfs 2.6.35.2-O/boot/initrd. img-2.6.35.2-generic

 

14. Copy the compiled kernel image:CP/usr/src/linux-2.6.35.2/ARCH/i386/boot/bzimage/boot/vmlinuz-2.6.35.2-generic

 

15. In the last step, modify grub and update the startup list:Update-grub

(If you need to manually edit grub. cfg, you can use gedit under the root account)

 

(Note: Ubuntu 10.04 uses grub2 to manage startup settings, rather than grub. Therefore, you cannot find the menu in the previous/boot/GRUB path. because grub2 already uses/boot/GRUB/grub. CFG is used to manage configuration startup settings, but it is recommended that you do not manually compile this file. The specific method is to edit/etc/default/grub and/etc/grub. d. For detailed tutorials on grub2, see https://docs.google.com/Doc? Docid = 0aevq5pqmbeaozgc0czgyowtfmj1_bwo0odvoyw & HL = en
)

 

16. Reboot machine, then enjoy it!

 

 

 

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.