Why to configure the kernel
Select the required functions based on hardware and software requirements and remove the unwanted functionality.
Method of kernel configuration
Make config: text-based interaction configuration.
Make Menuconfig: Configuration based on the Graphics menu.
Make Menuconfig Configuration method
1. Classification of menu items
Processor type and features processor types
Networking Support Network Protocols
Device Driver Support Drivers
File Systems FileSystem Support
2. How to choose a menu item
<, which indicates that the feature is not selected.
<*> the source file (. c) that corresponds to the feature is compiled into an intermediate file (. o) and then merged into the kernel image, which eventually runs in memory. You need to always use the feature to select this method.
<m>, which indicates that the source file (. c) corresponding to the feature is first compiled into an intermediate file (. ko) and then centralized into the appropriate folder. The module is eventually stored on the secondary and then dynamically loaded into memory when it is needed. You do not need to always use the feature to select this method.
3. configuration File Save location
The. config file in the same directory as the makefile file saves the configuration result, which is a hidden file and can be seen through the ls–a command. Each item in the file corresponds to each item in the menu item. Select Help in the configuration menu to see the name of the corresponding item.
4. How to configure the kernel configuration
4.1. Select an existing configuration file to simplify the configuration.
4.2. Unclear configuration items are saved as default values.
Configuration and compilation of the kernel
1. Configuring the kernel configuration file
1.1. Copy the configuration file
Copy the/boot/config in the Linux system on the PC ... Kernel configuration file into the kernel source code. The corresponding reference configuration file is also saved in the Arch/<cpu>/configs folder.
1.2. Loading the configuration file
Make Menuconfig->load an alternate configuration File->exit->yes
1.3. Modify the configuration file
Make menuconfig->networking options->< >the IPv6 protocol->exit->yes
2. Compiling kernel images
Modules selected as <*> will be compiled into a kernel image file (zimage)
Example:
Make Zimage
Make Bzimage
Displaying detailed compilation information using the V=1 option
Make Zimage V=1
Make Bzimage V=1
The compiled kernel is located in the arch/<cpu>/boot/directory
3. Compiling kernel modules
Modules selected as <M> will be compiled into kernel module files
Example:
Make modules
4. Move the kernel module
The compiled kernel modules are scattered across the kernel directory and moved to the/lib/modules/directory of the system root by moving the kernel modules.
Example:
Make Modules_install
5. Package kernel module (make RAMDisk)
Format:
MKINITRD initrd-$version $version
Example:
MKINITRD initrd-2.6.39 2.6.39
$version represents the corresponding folder name under the/lib/modules/directory, and the initrd-2.6.39 file is generated under the directory where the command is run
6. Install kernel files (x86)
1. Copy the kernel image
CP arch/x86/boot/bzimage/boot/vmlinuz-2.6.39
2. Copy kernel modules
CP initrd-2.6.39/boot/
3. Modify the Startup file
Vim/etc/grub.conf
Title Red Hat Enterprise Linux (2.6. ) root (hd0,0) /vmlinuz-2.6. root=/dev/mapper/volgroup-lv_root ro rd_no_luks rd_no_md rd_lvm_lv=volgroup/lv_swap Crashkernel=128M LANG=zh_ CN. utf-8 rd_lvm_lv=volgroup/lv_root keyboardtype=pc keytable=US rd_no_dm rhgb quiet / initrd-2.6. the
4. Reboot the system
Uname–r Viewing the kernel version
7. Clean up kernel files
1. The. config file was generated during the configuration phase
2. During compilation, many intermediate files (. o) are produced, some intermediate files become kernel images (zimage), and others become kernel modules (. ko)
Example:
Make clean clears the files generated by the compilation
Make Distclean clean up the files generated by the configuration and compilation
[Country EMBED strategy] [099] [Linux kernel configuration and compilation]