Linux Kernel configuration and compilation (X86 platform) __linux

Source: Internet
Author: User

Linux kernel Configuration and compilation (X86 platform)

This article turns from: http://www.linuxidc.com/Linux/2013-07/87360.htm

Note: Only for learning Exchange

Objective:

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

(2): Install the compiled kernel under VMware and start

Tools:

gcc compiler, Linux-2.6.29 kernel

steps:

(a): Clear temporary files, intermediate files and configuration files, etc. (just downloaded from the Internet file 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 compilation-generated files, as well as kernel configuration files, plus a variety of backup files.

Make Distclean

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

(ii) Select the reference profile

Use the running kernel configuration file as a reference compounding file, which is 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: A text-mode-based menu configuration (highly recommended).

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

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

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

1, the use of directional keys in the movement between the options;

2, use the "enter" key to go to the next Level menu; The highlight letter on each option is a keyboard shortcut that you can use to quickly reach the selected item you want to set.

3, in parentheses, press "Y" to compile the project into the kernel, press "M" to compile as a module, press "n" to not select (press SPACEBAR to also compile into kernel, compile as module and do not compile three switch), 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 get the new profile the Linux kernel provides a series of reference kernel profiles located in the arch/$cpu/configs

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

(iv) compiling the kernel

(1): Make Zimage

(2): Make Bzimage

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

For detailed compilation information, you can use:

Make Zimage V=1

Make Bzimage V=1

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

(v) compiling kernel modules

Use command make modules

The kernel module compiles for a longer period of time and typically takes 1-2 hours. The modules are derived from the <m> items selected in the menu configuration interface that is started using command make menuconfig.

(vi) installation of kernel modules

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

(vii) Production of Init RAMDisk

Use the CD to beat linux-2.6.29/, directory of the upper directory, using the command: mkinitrdinitrd-$version $version (mkinitrd initrd-2.6.29 2.6.29) The module directory 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 file system 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 will only serve as a bridge to real-world file systems. In an embedded system without a storage device, INITRD can be a permanent root file system.

Many distributions of Linux use INITRD primarily to determine which hardware drivers need to be loaded, which are not needed, if there are problems with the file system, and ultimately to allow the root partition to load smoothly. 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 kernel files and init RAMDisk from the/boot directory, so you need to copy the kernel and INITRD to the/boot directory. To use the command:

CP Initrd-2.6.29/boot

CP linux-2.6.29/arch/x86/boot/bzimage/boot/vmlinuz-2.6.29

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

In order for GRUB to provide an option for our own Linux kernel at startup, we need to modify the Grub profile/etc/grub.conf. (The code that you add is the title of 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 in the/boot/grub directory.

(10): Reboot the system

Using command reboot, reboot the system, hold down the SPACEBAR until you enter the Grub interface and select My Linux (2.6.29) boot.

Recommended reading:

Linux Kernel Source Code scenario analysis (up and down complete HD edition) PDF http://www.linuxidc.com/Linux/2013-04/82908.htm

Linux kernel-Driven Development kgdb single-step debugging kernel http://www.linuxidc.com/Linux/2013-06/86233.htm

Related Article

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.