About how to create a new Linux Kernel

Source: Internet
Author: User
Tags rpmbuild

It is particularly worth mentioning that the Linux kernel source code package must be learned. Here we will mainly discuss the introduction of the Linux kernel, including the introduction of the new Linux kernel installation. Basic Linux knowledge, including the installation of Fedora, disk partitioning, and basic Linux operations, aims to give readers a preliminary understanding of Linux. It involves file management, disk management, user and group management, man help, software package management, File compression, and printer management.

Download the latest Linux 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 to download

Decompress the source package

(Some people say that it is incorrect to decompress the source code to the/usr/src directory. You can decompress it 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

Configuration 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 the Linux 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 Linux 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 Linux kernel identifier vim Makefile EXTRAVERSION =. custom-1 (row 4th)

Traditional compilation

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)

RPM Compilation

The RPM package is generated to facilitate the use of 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, Linux 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 Linux kernel identifier has been added to the package name.

Install new Linux Kernel

Now go to the existing Directory of the new rpmLinux 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 Linux kernel .)
Next we will create a ramdisk for the new Linux kernel. Otherwise, the system will not be able to guide the new Linux 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 Linux kernel information already exists (working) on your system, copy an instance, and replace it with your new Linux kernel and ramdisk: vim/boot/grub/menu. lst

For example, in my menu. lst, before I add new Linux 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)

Restart the system and select linux-2.6.31.custom-1 from the Grub boot menu. Reboot. After the restart, you are done. Your new Linux kernel has been installed.

  1. Handling Linux kernel security details
  2. Introduction to Linux kernel Virtual Machine Installation
  3. Comprehensive Understanding of Linux kernel cyclic linked list
  4. Linux Kernel unified device system operations
  5. Handling Linux kernel security details

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.