Article Title: Compile the kernel under Fedora. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Step 1: download the latest kernel source code package from the official website.
Official Website: www.kernel.org
Latest Version: 2.6.31, download URL: linux/kernel/v2.6/linux-2.6.31.tar.bz2 "> http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2
You can use wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2 to download
Step 2: Decompress the source code package (Some people say that it is incorrect to decompress the source code to the/usr/src directory. You can decompress the package to any directory)
Cd ~ Wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2
Tar-jxvf linux-2.6.31.tar.bz2
Step 3: Configure options
Cd linux-2.6.31
Cp/boot/config-'uname-R'. config
Make mrproper (delete the garbage generated by the last compilation, not required for the first compilation)
Make menuconfig (Enable kernel option configuration interface)
Description, make menuconfig will find the. config configuration file under the linux-2.6.31 directory, if not found, use the CPU-related config file as the default configuration. Of course, we can also copy the configuration of the current system as a comparison, such as cp/boot/config-'uname-R'. config (. config is the hidden file ls-a to view)
Note: If the kernel is compiled in the same version, you need to back up the current module.
Cd/lib/modules
Mv 2.6.31 2.6.31 _ old
Specify the kernel identifier
Vim Makefile
EXTRAVERSION =. custom-1 (row 4th)
Step 4 (1): compile in traditional mode
Make all (for versions earlier than 2.6, run the following command manually)
(
# Make dep <= establishes dependency attribute relationships!
# Make clean <= remove old data!
# Make bzImage <= start to compile the core! This core is compressed (about 30 minutes)
# Make modules <= start compiling the module! This action depends on the number of modules you just compiled! (About 1 hour)
)
Make modules_install (install the module to/lib/modules/2.6.31), make install (the System will put vmlinuz and System. copy map to the/boot directory and modify grub/boot/grub/menu at the same time. for versions earlier than lst and 2.6, You need to manually copy vmlinuz and System. map)
Step 4 (2): RPM compilation generates an RPM package, which is convenient for others to use make rpm. After compilation is complete ~ /Rpmbuild/SRPMS/directory to find a new src. rpm package, such as. SRPMS/kernel-2.6.31.custom-1.src.rpm, kernel rpm package located in ~ /Rpmbuild/RPMS/i386/(or RPMS/i586/, RPMS/i686/, etc. see your platform type ). for example. RPMS/i386/kernel-2.6.31.custom-1.i386.rpm. you can see that the kernel identifier has been added to the package name.
Install new kernel
Now go to the existing Directory of the new rpm kernel package (based on your platform type, such .~ /Rpmbuild/RPMS/i386/) install the rpm package, cd ~ /Rpmbuild/RPMS/i386
Rpm-ivh kernel-2.6.31.custom-1.i386.rpm (now you can even copy to another Fedora system and install it in the above way. You will no longer need to compile the kernel .)
Next we will create a ramdisk for the new kernel, otherwise the system will not be able to boot the new kernel:
Mkinitrd/boot/initrd-2.6.31.custom-1.img 2.6.31.custom-1
Then edit/boot/grub/menu. in the lst file, check that the boot kernel information already exists (working) on your system, copy an instance, and replace it with your new kernel and ramdisk: vim/boot/grub/menu. lst
[1] [2] Next page