Linux Kernel compilation process (kernel2.6.7)

Source: Internet
Author: User

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. Compiling the kernel is not difficult. if you can follow the correct method, it will take up to one and a half hours. 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/

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 compilation processes

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/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 (2.4.20-
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 vmnet-only.

If the above operation still fails, the other solution is.

4) USB Problems

Most USB modules used in the new 2.6.0 kernel have been renamed, so you need to modify the code for USB subsystem initialization in/etc/rc. sysinit. Change all "keybdev" in this file to "usbkbd", "mousedev" to "usbmouse", and "/proc/bus/USB" to "/sys/bus/USB ", and in/etc/init. d/halt. In addition, you must find "needusb storage" in/etc/rc. sysinit and make the following changes:

Needusbstorage =
If [$ USB = "1"]; then
Needusbstorage = 'lc _ all = C grep-e "^ I. * CLS = 08"/sys/bus/USB/Devices 2>/dev/null'
Action $ "Initializing USB 1.1 host controller:" modprobe OHCI-HCD 2>/dev/null
Action $ "Initializing USB hid interface:" modprobe hid 2>/dev/null
Action $ "Initializing USB keyboard:" modprobe usbkbd 2>/dev/null
Action $ "Initializing USB mouse:" modprobe usbmouse 2>/dev/null
Fi

Change "OHCI-HCD" to "EHCI-HCD" if the USB Bus is 2.0 ".

5) sysfs Problems

Solution:

◆ Create a directory/sys: # mkdir/sys

◆ In the/etc/rc. d/rc. sysinit file, find "Mount-F/proc" and add "Mount-F/sys" to the next line ".

◆ Similarly in/etc/rc. d/RC. in the sysinit file, locate "Action $" mounting proc filesystem: "Mount-n-t proc/proc" and add "Action $" mounting sysfs filesystem: "Mount-n-t sysfs/sys ".

◆ Add "NONE/sys sysfs defaults 0 0" to the/etc/fstab file ".

◆ Find "awk" $2 ~ In the halt_get_remaining function of/etc/init. d/halt ~ /^ // $ | ^ // Proc | ^ // DEV/{next} ", changed to" awk "$2 ~ /^/$ | ^/Proc | ^/sys | ^/dev/{next }".

6) hotplug (hot swapping) Problems

Kernel support for hot swapping is related to the kmod kernel thread.

The solution is to replace all/proc/ksyms in/etc/rc. sysinit with/proc/kallsyms. Run the following command:

# Mv/etc/rc. d/rc. sysinit/etc/rc. d/rc. sysinit. Bak
# Sed-E's // proc // ksyms // proc // kallsyms/G'/etc/rc. d/RC. sysinit. bak>/etc/rc. d/RC. sysinit

7) glibc Problems

You can upgrade the software package of the glibc standard library to solve this problem. Some distributions, such as glibc installed by default on Red Hat 9.0, may have been modified by the Red Hat kernel team. The software package is:

Bytes.

You can upgrade it together with the following software packages:

Ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/ OS /i386/glibc-common-2.3.2-27.9.i386.rpm

Ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/ OS /i386/glibc-devel-2.3.2-27.9.i386.rpm

Ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/ OS /i386/glibc-utils-2.3.2-27.9.i386.rpm

If you fail to use "rpm-uvh glibc *", run the "rpm-e" command to delete the old glibc, and then run the "rpm-uvh -- force glibc *" command to force the installation.

Other problems

You may encounter other problems, but you can follow these steps to solve them:

1. Compile the kernel components into modules as much as possible. Run the following command to quickly reconstruct the kernel:

# Make all modules_install install

2. most software failures occur because the module name has been changed, and/etc/rc. d/RC. sysinit and/etc/rcX. the script in D/* does not modify these values. Therefore, modifying related entries in turn can be improved, but this requires a lot of background knowledge. If you are in trouble, you can concentrate all the commands for Loading modules in/etc/rc. d/rc. Local. For example:

Modprobe eth0
Modprobe isofs
Modprobe Loop
Modprobe vfat

Modify the/etc/modoribe. conf file at the same time. For more information, see "Man modoribe. conf.

3. if you want to know the name of a module after the change, you can first find this option in "make menuconfig" and select help to find its configuration name (config _*), search for config _ * In makefile of the source code directory _*. Generally, you can find the obj-$ (config _ *) item. Its value is the name of the module.

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.