Compile Linux Kernel

Source: Internet
Author: User
Compile the Linux kernel-general Linux technology-Linux programming and kernel information. The following is a detailed description. 1. Download http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2to /usr/src
2.
# Cd/usr/src
# Tar xjvf linux-2.6.24.tar.bz2
# Cd linux-2.6.24
# Make mrproper
# Make menuconfig
# Make clean
# Make bzImage
# Make modules
# Make modules_install
# Cp System. map System. map-2.6.24
# Mkinitrd/boot/initrd-2.6.24.img 2.6.24
# Vi/boot/grub. conf

# Grub. conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a/boot partition. This means that
# All kernel and initrd paths are relative to/, eg.
# Root (hd0, 0)
# Kernel/boot/vmlinuz-version ro root =/dev/sda1
# Initrd/boot/initrd-version.img
# Boot =/dev/sda
Default = 0
Timeout = 5
Selinux = 0
Splashimage = (hd0, 0)/boot/grub/splash.xpm.gz
Hiddenmenu
Title Fedora Core (2.6.18-1.2798.fc6)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.6.18-1.2798.fc6 ro root = LABEL =/1
Initrd/boot/initrd-2.6.18-1.2798.fc6.img
Title Linux (2.6.24)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.6.24 ro root = LABEL =/1
Initrd/boot/initrd-2.6.24.img

Explanation:
# Make mrproper
If this is the first compilation, you do not need to execute this command. The purpose of this command is to clear the original directory. config and. o (object) file, but if you have compiled the kernel multiple times, this step is required, otherwise there will be many minor problems in the future

# Make menuconfig
Configure the kernel options to compile the kernel. There are four methods
# Make config (the most traditional text-based configuration interface is not recommended)
# Make menuconfig (Text menu-based configuration interface, recommended for character terminals)
# Make xconfig (the configuration interface based on the graphic window mode is recommended in Xwindow)
# Make oldconfig (if you only want to modify some small points based on the original Kernel configuration, it will save a lot of trouble)
For details about the options, refer.
In make menuconfig, some choose [], some choose [M], and some choose []. * indicates that the selected file is directly loaded into the kernel, M indicates that it will be compiled into modules in later make modules, and can be transferred to the kernel at any time through insmod and modprobe.
Many articles say that make dep should be executed after make menuconfig is executed, but I will prompt *** Warning: make dep is unnecessary now when executing make dep. maybe the new kernel does not need to execute make dep.

# Make clean
Clear unnecessary files. If not executed, errors may occur during compilation.

# Make bzImage
Generate the Kernel File Based on the selected kernel options. If the generated Kernel File is at kb, you can also use make zImage. However, make bzImage is recommended.

# Make modules
Compile all the options selected as M in make menuconfig into modules and place them in/usr/src/linux-2.4.24/

# Make modules_install
Install the compiled modules under/lib/modules/2.6.24

# Cp System. map System. map-2.6.24
2.6.24 indicates the version of the kernel, for System. map reference http://blog.csdn.net/ryman/archive/2004/10/27/154697.aspx

# Mkinitrd/boot/initrd-2.6.24.img 2.6.24
If the SCSI hard disk is used and the ext3 partition format is used, make sure to make initrd. img (because the scsicard driver is included in this), if you are using an IDE hard disk, you can skip this step. 2.6.24 is 2.6.24 under/lib/modules/, which is generated by make modules_install.

# Vi/boot/grub. conf
Edit grub. conf and insert
Title Linux (2.6.24)
Root (hd0, 0)
Kernel/boot/vmlinuz-2.6.24 ro root = LABEL =/1
Initrd/boot/initrd-2.6.24.img
/Boot/vmlinuz-2.6.24 is the path to the new kernel
/Boot/initrd-2.6.24.img is generated by mkinitrd/boot/initrd-2.6.24.img 2.6.24

Restart. Select Linux (2.6.24) When grub is started to start the system with the new kernel. If you want to modify the default kernel, run/boot/grub. change default = 0 in conf to 1. For details, refer to grub. conf configuration.

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.