Linux Kernel Compilation

Source: Internet
Author: User

The new kernel can be downloaded in the http://www.kernel.org.

Copy linux-2.6.18.2.tar.bz2/Usr/src/Below

Tar-Jxvf linux-2.6.18.2.tar.bz2

CD linux-2.6.18.2

 

Make mrproperDelete the garbage generated by the original compilation

 

You can use one of the following commands to configure the kernel based on your needs and hobbies:

# Make config (text-based most traditional configuration interface)

# Make menuconfig (Text menu-based configuration interface)

# Make xconfig (graphical window mode-based configuration interface)

# Make oldconfig (if you only want to modify some small points based on the original Kernel configuration, it will save a lot of trouble)

 

During configuration, the default values can be used for most options. Only a small part of options need to be selected based on the user's needs. For example, if you want the kernel to support a file system with DOS partitions, You need to select fat or dossystem for the file system. If the system is equipped with a NIC or PCMCIA card, select the type of the corresponding card in the network configuration.

When you select the corresponding configuration, there are three options, which represent the following meanings:

"Y"-compile this function into the kernel

"N"-do not compile this function into the kernel

"M"-compile this function into a module that can be dynamically inserted into the kernel as needed.

Compile some functional code that is far away from the other parts of the core and is not frequently used into a loadable module. This helps reduce the length of the kernel and reduce the memory consumed by the kernel, this feature simplifies the impact on the kernel when the corresponding environment changes. Many functions can be processed in this way, such as NIC support and file system support such as fat.

In fact, the most important thing to compile the kernel is to configure the kernel. I generally useMake menuconfigConfigure the kernel.

When you configure the 2.6.0 kernel, if your motherboard is an Intel chip, you may get a satisfactory kernel by default. Make menuconfig and save it when it leaves.

The difficulty here is PCI. If your hard disk is IDE, you must choose the nanqiao chip on your motherboard. For SCSI, select your scsicard model.

There is also the model of the NIC and sound card chip. You can use lspci to find their models.

 

[Root @ Leo boot] # lspci

00:00. 0 host bridge: Intel Corp. Sort BX/ZX/DX-Sort 43bx/ZX/dx host bridge (Rev 01)

00:01. 0 PCI Bridge: Intel Corp. Sort BX/ZX/DX-Sort 43bx/ZX/dx AGP bridge (Rev 01)

00:07. 0 ISA Bridge: Intel Corp. 82371ab/EB/MB piix4 ISA (Rev 08)

. 1 ide interface: Intel Corp. 82371ab/EB/MB piix4 IDE (Rev 01)

00:07. 2 USB controller: Intel Corp. 82371ab/EB/MB piix4 USB

. 3 Bridge: Intel Corp. 82371ab/EB/MB piix4 ACPI (Rev 08)

00: 0f. 0 VGA compatible Controller: VMware Inc [VMware svga II] PCI display adapter

. 0 SCSI Storage Controller: LSI logic/symbios logic 53c1030 PCI-X fusion-MPT dual ultra320 SCSI (Rev 01)

. 0 Ethernet controller: Advanced Micro Devices [amd] 79c970 [pcnet32 Lance] (Rev 10)

. 0 multimedia audio Controller: ensoniq es1371 [AudioPCI-97] (Rev 02)

 

Compile 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.

 

# Make Dep(Ensure that the key files are in the correct location) 2.5.*-2.6.0 is not required. In fact,. * Some kernels are not required.

# Make clean(Make sure all related files are in the latest version)

# Make zimage (compile the compressed kernel)

When the kernel supports many peripherals and functions, the kernel may become very large. In this case, you can compile the large kernel:

# Make bzimage

The Compilation Time is related to factors such as hardware conditions and Kernel configuration of the machine. The obtained kernel is located/Usr/src/Linux/ARCH/i386/bootDirectory. Assume that the user's CPU is x86.

If you select a loadable module, compile the selected module after compiling the kernel:

# Make modules(Compile the selected module)

# Make module_install(Transfer the compiled module to the standard system location)

 

# Make install

 

The above command "make install" will:

(1) copy the compressed kernel image to the/boot directory and create the system. map symbolic link;

(2) modify the configuration file of the bootloader;

(3) Call the mkinitrd program to create the initrd image of the kernel. for grub, add the following similar configuration lines in the/boot/GRUB/grub. conf configuration file:

 

Title Red Hat Linux (2 .***)

Root (hd0, 1)

Kernel/boot/vmlinuz-2. *** Ro root = label =/

Initrd/boot/initrd-2. ***. img

The standard directory of the module in the system is located in/lib/modules/X. y. z, followed by X. y. Z is the version number. For security reasons, it is best to back up/lib/modules before running # Make modules_install. A module is usually a file with the. O Extension.# LsmodList the modules of the current kernel.

GenerallyMake bzimage; Make modules; Make module_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/volgroup00/logvol00

# Initrd-version.img/initrd

# Boot =/dev/hda

Default = 0

Timeout = 5

Splashimage = (hd0, 0)/GRUB/splash.xpm.gz

Hiddenmenu

Title Fedora Core (2.6.18.2)

Root (hd0, 0)

Kernel/vmlinuz-2.6.18.2 Ro root =/dev/volgroup00/logvol00 rhgb quiet

Initrd/initrd-2.6.18.2.img

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 rhgb quiet

Initrd/initrd-2.6.18-1.2798.fc6.img

 

Restart the machine to test the latest kernel.

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.