Linux kernel-driven learning (i)----Kernel Introduction | Configuration | compiling | Installation (under PC platform)

Source: Internet
Author: User

Linux Architecture:

Knowledge: Linux architecture is divided into user space and kernel space
What is the reason for dividing into user space and kernel space? Protect the operating system so that the application and the kernel have different permissions. Create different levels for different codes ...
Kernel space and user space aretwo different states of program executionPasssystem CallsAndHardware InterruptsAbility to convert from user space to kernel space
the composition of the kernel:
a--> System Call Interface (SCI),b--> Process Management (PM),c--> Memory Management (MM),d--> about Processor code (arch),e--> Virtual file System (VFS),f--> Network protocol stack,g--> device driver (DD)


about the Linux kernel source code 1.Download Source Codes www.kernel.org 2.Directory structure
3.The main use of sourceinsight in the project to manage the kernel source code
————————————————————————————————————————————————————————————— 1. Configuring the kernel
1.1 The reason for configuring the kernel: --->1.1.1, hardware requirements --->1.1.2, Software requirements, select the need, remove the
1.2 How to configure the kernel (two commands) --->1.2.1, Interactive settings based on text mode make config (need to be selected individually, more cumbersome)
--->1.2.2, Interactive settings based on menu mode make menuconfig(more intuitive, this command defaults to the X86 platform, you need to specify ARCH = arm when configuring the arm platform)


the kernel configuration in menu mode is more intuitive, so choose Menu mode to configureabout menu options Description:<*>; Compile the selected C files to generate the corresponding intermediate files (*.O), compiled by these (*.O) files to form the kernel image (Zimage), when the kernel image is put into memory at startup<m>: Represents the module, corresponding to each module has a corresponding C file, compile the corresponding intermediate file (*.O). and put the intermediate files on the hard drive, and then put them in memory when they need to be used<>: Indicates that the feature is not selected at compile time
Save the settings after the configuration is complete. You can see the extra . config file in the kernel root, and each line in the file corresponds to an option for the configuration as shown
Note: You can also modify the kernel options by modifying the. config file . as followsconfig_x86_32 is not set  It is more complex to configure kernel options from a zero start. There are two ways to configure the kernel primarily:The first method: generally choose an existing kernel configuration file as the basis for configuration. For example, select the configuration file under Linux in the virtual machine.
go to the Kernel Options configuration menu, and select Load ..... as follows (note: The Linux configuration file (config-2.6.32-279.el6.i686) should be placed in the top-level directory of the kernel folder at this time)You can then modify it.

The second method : Refer to the configuration files of different platforms in/arch/arm/configs/in the kernel file directory

2. Compile the kernel 2.1 compiling kernel images (also involving two commands)----The final image file of the file that corresponds to the <*> option --->2.1.1 command make zimage---on x86 platform, Zimage can only be used for cores less than 512K
--->2.1.2 command make Bzimage:
to get detailed compilation information , you can use the Make zimage v=1make Bzimage v=1---can list the more complete compilation options
follow the prompts; the compiled file is placed in this directory, path: Arch/x86/boot/bzimage

2.2. compiling kernel module files (two commands below)----corresponding <M> options generated (. ko) files
--->2.2.1 command make modules compile kernel modules for a long time---
--->2.2.2 command make Modules_install---put the modules scattered in the Linux folder together---/lib/modules directory
2.3 packaging kernel modules; making init RAMDiskcommand: MKINITRD initrd-$version (can be arbitrarily named) $version (this is the file directory that was just compiled, package this directory)Example:mkinitrd initrd-2.3-32 linux-2.3-32

3, install the kernel (x86 platform only operation) 3.1 copy kernel: Copy the compiled bzimage to the startup directory. CP arch/$cpu/boot/bzimage/boot/vmlinuz-$version 3.2 Copy the second part of the produced initrd-$version to the/boot/directoryexecute CP initrd-$version/boot/ 3.3 Modifying the boot configuration file, the/etc/grub.conf file
4. Clean the kernel 4.1 command make clean---clear the. o File generated by the compilationthe 4.2 command make Distclean---clear the. o files and configuration files generated by the compilation. config


Linux kernel-driven learning (i)----Kernel Introduction | configuration | compilation | installation (under PC 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.