Linux Kernel compilation details

Source: Internet
Author: User
Linux Kernel compilation details-general Linux technology-Linux programming and kernel information. The following is a detailed description. Unbind the source code package under the/usr/src/directory to obtain the source code directory/usr/src/linux-2. ***/. before doing anything to the kernel, we recommend that you take a look at its README file and Documentation/Changes file, from which you will get a lot of useful information. This information will help you avoid unnecessary troubles in the subsequent upgrade process.

The Documentation/Changes provides minimum system software requirements for successful upgrade to the kernel-2.6.x, such as for kernel-2.6.18.2:



O Gnu C 3.2 # gcc -- version

O Gnu make 3.79.1 # make -- version

O binutils 2.12 # ld-v

O util-linux 2.10o # fdformat -- version

O module-init-tools 0.9.10 # depmod-V

O e2fsprogs 1.29 # tune2fs

O jfsutils 1.1.3 # fsck. jfs-V

O reiserfsprogs 3.6.3 # reiserfsck-V 2> & 1 | grep reis

Erfsprogs

O xfsprogs 2.6.0 # xfs_db-V

O pcmciautils 004

O pcmcia-cs 3.1.21 # cardmgr-V

O quota-tools 3.09 # quota-V

O PPP 2.4.0 # pppd -- version

0 isdn4k-utils 3.1pre1 # isdnctrl 2> & 1 | grep version

O nfs-utils 1.0.5 # showmount -- version

O procps 3.2.0 # ps -- version

O oprofile 0.9 # oprofiled -- version

O udev 071 # udevinfo? V



Copy linux-2.6.18.2.tar.bz2 to/usr/src/first.

Tar? Jxvf linux-2.6.18.2.tar.bz2

Cd linux-2.6.18.2



Make mrproper deletes 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 usually use make menuconfig to configure 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 depends on the hardware conditions and Kernel configuration of the machine. The obtained kernel is located in the/usr/src/linux/arch/i386/boot directory, assume that the user's CPU is x86.

      

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

      

    # Make modules)

      

    # 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. 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. Use the command # lsmod to list the modules in the current kernel.

      

    I usually make bzImage; make modules; make module_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/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.
  • 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.