Linux kernel Configuration and compilation (X86 platform)

Source: Internet
Author: User

Description: For learning and communication only

Objective:

(1): Configure and compile the Linux-2.6.29 kernel under the X86 platform

(2): Install the compiled kernel and launch it under VMware

Tools:

gcc compiler, Linux-2.6.29 kernel

Steps:

(a): Clear temporary files, intermediate files and configuration files, etc. (just download the file from the Internet, this step can be omitted).

Make clean

Deletes most of the files generated by the compilation, but retains the kernel's configuration file. config.

Make Mrproper

Delete all compiled generated files, as well as kernel configuration files, plus various backup files.

Make Distclean

Mrproper deleted files, plus edit backup files and some patch files.

(ii) Select a reference configuration file

Use a running kernel configuration file as a reference configuration file in the/boot directory, using the command

Cp/boot/config-2.6.18-53.el5. config

(iii) Configuring the kernel

The configuration kernel has the following command:

Make config: Interactive configuration based on file mode (that is, a question-and-answer).

Make Menuconfig: Menu-based configuration in text mode (highly recommended).

Make Oldconfig: Use an existing configuration file (. config) but ask for additional configuration options.

Make Xconfig: Graphical configuration (requires the installation of a graphical system).

Make Menuconfig is the most commonly used kernel configuration method, using the following methods:

1. Use the arrow keys to move between the options;

2. Use "Enter" key to enter the next level menu; the highlighted letter on each option is a keyboard shortcut that allows you to quickly reach the selected item you want to set.

3. Press "Y" in parentheses to compile the project into the kernel, press "M" to compile as a module, press "N" for not selected (press the SPACEBAR can also be compiled into the kernel, compiled into the module and do not compile the three), press "H" will display the Help information of this option, press "ESC" key will return to the upper menu

Kernel configuration is usually based on an existing configuration file, modified to obtain a new configuration file The Linux kernel provides a series of reference kernel configuration files, located in arch/$cpu/configs

Note: The interface to run make Menuconfig needs to adjust the window size of the terminal, at least 80*19.

(d) Compile the kernel

(1): Make Zimage

(2): Make Bzimage

Difference: On the X86 platform, the zimage can only be used for cores less than 512Kd (note that the X86 platform)

For detailed compilation information, you can use:

The compiled kernel is located in the Arch/<cpu>/boot directory

(v) Compiling kernel modules

Using commands

Make  

Kernel modules compile for a long time, which typically takes up to 1-2 hours. These modules are derived from selecting the <m> item in the menu-based configuration interface launched using the command make menuconfig.

(vi) Installing kernel modules

Using the command: Make Modules_install, after the installation is complete, the compiled kernel module is copied from the kernel source code directory to the/lib/modules/2.6.29 directory.

(vii) Production of Init RAMDisk

Using CD bounce linux-2.6.29/, directory upper directory, use command: mkinitrdinitrd-$version $version (mkinitrd initrd-2.6.29 2.6.29) The module catalog that was generated in the previous step/lib/ Modules/2.6.29 made into initrd-2.6.29.

Tip: INITRD is the abbreviation for "initial RAMDisk", Initrd is an initial root filesystem that is mounted to the system before the actual root file system is available. In a desktop or server Linux system, INITRD is a temporary file system. Its life cycle is short and is used only as a bridge to the real file system. In an embedded system without a storage device, the INITRD can be a permanent root file system.

Many Linux distributions use INITRD primarily to determine which hardware drivers need to be loaded, which do not, and if the file system has problems, so that the root partition can be loaded successfully after the kernel is booted. Booting on SCSI and SATA devices, USB boot disks, diskless servers, etc. all require initrd to make judgments, which can improve the versatility of the Linux kernel.

(eight) Install the kernel

As the Linux system starts, it looks for the kernel files and init RAMDisk from the/boot directory, so you need to copy the kernel and INITRD to the/boot directory. Use the command:

<P>CP initrd-2.6.29&nbsp; /boot <P>CP linux-2.6.29/arch/x86/boot/bzimage/boot/vmlinuz-2.6.29 </P>

(ix) Modification of/etc/grub.conf or/etc/lilo.conf

In order for GRUB to provide an option for our own Linux kernel at boot time, we need to modify the Grub configuration file/etc/grub.conf. (the added code is the title My Linux (2.6.29) below)

Note:/etc/grub.conf is actually a link to/boot/grub/grub.conf, so the real configuration file exists with the/boot/grub directory.

(10): Restart the system

Using the command reboot, restart the system, press and hold the SPACEBAR until you enter the Grub interface and select My Linux (2.6.29) to start.

Linux kernel Configuration and compilation (X86 platform)

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.