Compile the kernel in Fedora

Source: Internet
Author: User
Tags rpmbuild

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: 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
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.
Press 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 is used as the default configuration. Of course, we can also copy the configuration of the current system as a comparison, as shown in figure
CP/boot/config-'uname-R'. config (. config is used to hide the LS-a file)

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 will generate an RPM package for your convenience.
Make rpm
After compilation ~ /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 the file to other fedora systems and install it in the above way. You 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

For example, in my menu. lst, before I add new kernel information:
# Grub. conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# Notice: You have a/boot partition. This means that
# All kernel and initrd paths are relative to/boot/, eg.
# Root (hd0, 0)
# Kernel/vmlinuz-version Ro root =/dev/volgroup00/logvol00
# Initrd-version.img/initrd
# Boot =/dev/SDA
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/GRUB/splash.xpm.gz
Hiddenmenu

Title Fedora Core (2.6.18-1.2798.fc6)
Root (hd0, 0)
Kernel/vmlinuz-2.6.18-1.2798.fc6 Ro root =/dev/volgroup00/logvol00
Initrd/initrd-2.6.18-1.2798.fc6.img

After modification:

# Grub. conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# Notice: You have a/boot partition. This means that
# All kernel and initrd paths are relative to/boot/, eg.
# Root (hd0, 0)
# Kernel/vmlinuz-version Ro root =/dev/volgroup00/logvol00
# Initrd-version.img/initrd
# Boot =/dev/SDA
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/GRUB/splash.xpm.gz
Hiddenmenu

Title Fedora Core (2.6.18-custom-2.6.18.2)
Root (hd0, 0)
Kernel/vmlinuz-2.6.18-custom-2.6.18.2 Ro root =/dev/volgroup00/logvol00
Initrd/initrd-2.6.18-custom-2.6.18.2.img

Title Fedora Core (2.6.31.custom-1)
Root (hd0, 0)
Kernel/vmlinuz-2.6.31.custom-1 Ro root =/dev/volgroup00/logvol00
Initrd/initrd-2.6.31.custom-1.img

(You can use the following command to find the correct vmlinuz and initrd files:
Ls-L/boot
)

Step 5: restart the system, select linux-2.6.31.custom-1 from the grub boot menu.
Reboot

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.