Linux kernel compilation process (kernel2.6.7)

Source: Internet
Author: User
Article title: kernel compilation process (kernel2.6.7 ). 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.
It took several days to compile kernel2.6.7 successfully. The process was really difficult! "Now I can finally enjoy it for a while. many of my friends know little about the operation sequence and some important configurations or are unknown. in addition, the large amount of information on the Internet is complicated, which makes the success rate of compiling the kernel not high, and even causes the original system crash. I am one of them.
  
In fact, it is not difficult to compile the kernel. if you can follow the correct method, it will take up to one and a half hours to complete. is it very encouraging!
  
Now let's get started. my original system is redhat9.0, kernel 2.4.20-8, and compiled kernel 2.6.7, which is for your reference only.
  
There are four parts: preparations before compilation-> compilation configuration-> compilation process-> run the kernel Frequently Asked Questions
  
   Preparations before compilation
  
1. download a copy of the internal source code. the following code is linux-2.6.7.tar.bz2. you can download it or update it at the following URL.
  
Http://kernel.org/pub/linux/kernel/v2.6/ linux/kernel/v2.6/>
  
2) Download the latest version of module-init-tools ("module-init-tools-3.0.tar.gz" and "modutils-2.4.21-23.src.rpm ")
  
Http://www.kernel.org/pub/linux/kernel/people/rusty/modules/module-init-tools-3.0.tar.gz
  
Http://www.kernel.org/pub/linux/kernel/people/rusty/modules/modutils-2.4.21-23.src.rpm
  
3) install module-init-tools. it replaces depmod [/sbin/depmod] and other tools.
  
Tar-zxvf module-init-tools-3.0.tar.gz
  
Cd module-init-tools-3.0
  
./Configure -- prefix =/sbin
  
Make
  
Make install
  
/Generate-modprobe.conf/etc/modprobe. conf
  
4) install modutils-2.4.21-23.src.rpm. you may see the warning "user rusty and group rusty not existing. it doesn't matter. you only need to force the installation. if you do not perform these steps on Redhat 9 and Redhat 8, you will encounter problems in the "make modules_install" step.
  
Rpm-I modutils-2.4.21-23.src.rpm
  
Rpmbuild-bb/usr/src/redhat/SPECS/modutils. spec
  
Rpm-Fi/usr/src/redhat/RPMS/i386/modutils-2.4.21-23.i386.rpm
  
5) decompress the kernel source code and put the downloaded source code package under/usr/src. then
  
Cd/usr/src
  
Tar xvfj linux-2.6.7.tar.bz2
  
Cd linux-2.6.7
  
   Second compilation configuration
  
Please pay special attention to the configuration of several important modules in this part. Generally, use the "make menuconfig" command to configure the kernel.
  
Enter the preceding command and a menu interface appears. you can view the required modules. The following describes several important configurations.
  
1) file system
  
Make sure to select the ext3 file system,
  
File systems --->
  
[*] Ext3 journalling file system support
  
[*] Ext3 Security Labels
  
[*] JBD (ext3) debugging support
  
The above three items must be selected, and must be built in (that is, the mark *). this is very important. check after configuration. does the config file contain "CONFIG_EXT3_FS = y. if it is not "CONFIG_EXT3_FS = y" but "CONFIG_EXT3_FS = m", you will encounter the following error when running the kernel: too Troot: effect_root (/sysroot,/sysroot/initrd) failed
  
2) NIC driver
  
Make sure to compile the driver corresponding to your Nic into the kernel. the common Nic is realtek 8139. The following is the Nic configuration for your reference.
  
Device Drivers --->
  
Networking support --->
  
Ethernet (10 or 100 Mbit) --->
  
<*> RealTek RTL-8139 C + PCI Fast Ethernet Adapter support (EXPERIMENTAL)
  
<*> RealTek RTL-8139 PCI Fast Ethernet Adapter support
  
3) sound card drive
  
You also need to compile the driver corresponding to your own sound card into the kernel. the general sound card is i810_audio. The following is the configuration of this sound card for your reference.
  
Device Drivers --->
  
Sound --->
  
<*> Sound card support
  
Advanced Linux Sound Architecture --->
  
<*> Advanced Linux Sound Architecture
  
<*> Sequencer support
  
<> Sequencer dummy client
  
<*> OSS Mixer API
  
<*> Oss pcm (digital audio) API [*] OSS Sequencer API
  
<*> RTC Timer support
  
PCI devices --->
  
<*> Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111
  
Open Sound System --->
  
<> Open Sound System (DEPRECATED)
  
The above three configurations are related to the normal operation of the new kernel. Please note that other configurations can be selected by default if they are not well understood.
  
   Three compilations
  
Compile with the following command. it may take more than an hour to relax.
  
Make bzImage
  
Make modules
  
Make modules_install
  
Make install
  
Before running the new kernel, check the content of/boot/grub. conf. the following configuration can be used as a reference.
  
# 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/hdc3
  
# Initrd-version.img/initrd
  
# Boot =/dev/hdc
  
Default = 1
  
Timeout = 10
  
Splashimage = (hd0, 0)/grub/splash.xpm.gz
  
Title Red Hat Linux (2.6.7)
  
Root (hd0, 0)
  
Kernel/vmlinuz-2.6.7 ro root = LABEL =/
  
Initrd/initrd-2.6.7.img
  
Title Red Hat Linux
  
Root (hd0, 0)
  
Kernel/vmlinuz-2.4.20-8 ro root = LABEL =/
  
Initrd/initrd-2.4.20-8.img
  
   4. FAQs about kernel running
  
1) RPM problems
  
After you enter the compiled kernel, some RPM-related commands cannot be used and the following error occurs:
  
Rpmdb: unable to join the environment
  
Error: db4 error (11) from dbenv-> open: Resource temporarily unavailable
  
Error: cannot open Packages index using db3-Resource temporarily unavailable (11)
  
Error: cannot open Packages database in/var/lib/rpm
  
No packages
  
The solution is to run the "export LD_ASSUME_KERNEL = 2.2.25" command, or write it to/etc/bashrc.
  
2) Sound problems
  
The module name of the sound part has also changed. My laptop's original sound card driver is i810_audio and has now changed to snd-intel8x0. Therefore, add the following content to/etc/modprobe. conf:
  
Alias char-major-14 soundcore
  
Alias sound snd-intel8x0
  
Alias sound-slot-0 snd-intel8x0
  
Alias snd-card-0 snd-intel8x0
  
Alias sound-service-0-0 snd-mixer-oss
  
Alias sound-service-0-1 snd-seq-oss
  
Alias sound-service-0-3 snd-pcm-oss
  
Alias sound-service-0-8 snd-seq-oss
  
Alias sound-service-0-12 snd-pcm-oss
  
Install snd-intel8x0/sbin/modprobe -- ignore-install sound-slot-0 &&
  
{/Bin/aumix-minimal-f/etc/. aumixrc-L>/dev/null 2> & 1;/bin/true ;}
  
Remove snd-intel8x0
  
{/Bin/aumix-minimal-f/etc/. aumixrc-S>/dev/null 2> & 1;/bin/true ;};
  
/Sbin/modprobe-r -- ignore-remove sound-slot-0
  
Then run modprobe sound to load the sound module and run the following command to verify the sound card driver:
  
# Cat/proc/asound/cards
  
The result is as follows:
  
0 [SI7012]: ICH-SiS SI7012
  
SiS SI7012 at 0xdc00, irq 11
  
3) VMware problems
  
Solution:
  
◆ Replace all "/proc/ksyms" in/usr/bin/vmware-config.pl with "/proc/kallsyms ". Use the "sed" command to achieve this goal.
  
◆ Re-run the script and use the kernel header file to compile the new kernel module. If an error occurs during compilation, enter/usr/lib/vmware/modules/sourceand use the following command to unpack vmnet.tar:
  
# Tar xvf vmnet.tar
  
◆ Enter the vmnet-only directory to modify the bridge. c file. Change "atomic_add (skb-> truesize, & sk-> wmem_alloc);" to "atomic_add (skb-> truesize, & sk-> sk_wmem_alloc );", change "protinfo" to "sk_protinfo" in a similar way ".
  
◆ Replace the vmnet-only command with vmmon.tar:
  
# Tar cvf vmmon.tar v
Related Article

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.