Linux kernel compilation and parameter configuration

Source: Internet
Author: User

Kernel

Kernel, is the core of an operating system. It is responsible for managing the system's processes, memory, device drivers, files, and network systems, which determine the performance and stability of the system. Linux as a free software, with the support of the vast number of enthusiasts, the kernel version is constantly updated. The new kernel fixes bugs in the old kernel and adds a lot of new features. If users want to use these new features, or want to tailor a more efficient, stable kernel to their own system, they need to recompile the kernel. This article will take Redhat Linux 6.0 (kernel 2.2.5) as the operating system platform, introducing the method of kernel compiling on Linux.

First, download the new kernel source code

Kernel, is the core of an operating system. It is responsible for managing the system's processes, memory, device drivers, files, and network systems, which determine the performance and stability of the system. Linux as a free software, with the support of the vast number of enthusiasts, the kernel version is constantly updated. The new kernel fixes bugs in the old kernel and adds a lot of new features. If users want to use these new features, or want to tailor a more efficient, stable kernel to their own system, they need to recompile the kernel. This article will take Redhat Linux 6.0 (kernel 2.2.5) as the operating system platform, introducing the method of kernel compiling on Linux.

Currently, there are many sites on the Internet that provide Linux source code, and readers can choose a faster site to download. The author is from the site www.kernelnotes.org downloaded the latest Linux development version of the kernel 2.3.14 source code, all the code is compressed into a file called linux-2.3.14.tar.gz.

Second, release the kernel source code

Because the source code is placed in a compressed file, the source code is released to the specified directory before the kernel is configured. First log in as root and enter the/USR/SRC subdirectory. If the user installs the kernel's source code while installing Linux, a linux-2.2.5 subdirectory is found. The source code for the kernel 2.2.5 is stored in this directory. In addition, you will find a link to the directory Linux. Delete the connection, and then copy the source files of the new kernel to the/USR/SRC directory.

(i), release kernel source code with tar command

# CD/USR/SRC
# TAR-ZXVF linux-2.3.14.tar.gz/
After the file is released successfully, a Linux subdirectory is generated in the/USR/SRC directory. It contains all the source code of the kernel 2.3.14.

(b), link/usr/include/asm,/usr/inlude/linux,/USR/INCLUDE/SCSI to the corresponding directory in the/usr/src/linux/include directory.
# Cd/usr/include
# RM-RF ASM Linux
# ln-s/usr/src/linux/include/asm-i386 ASM
# ln-s/usr/src/linux/include/linux Linux
# ln-s/USR/SRC/LINUX/INCLUDE/SCSI SCSI

(iii) Delete the remaining. o files and other subordinate files in the source code directory.

# Cd/usr/src/linux
# Make Mrproper

Third, configure the kernel

(i), start the kernel configuration program.
# Cd/usr/src/linux
# make Config
In addition to the above command, the user can also use the Make Menuconfig command to start a menu mode configuration interface. If the user installs the X Window System, you can also execute the make Xconfig command to start the kernel Configuration program under X window.

(b), configure the kernel

The kernel configuration program for Linux provides a range of configuration options. For each configuration option, the user can answer "y", "M", or "n". where "Y" means the support or device driver of the corresponding feature is compiled into the kernel; "M" means that the support or device driver for the corresponding feature is compiled into a loadable module, which can be added to the kernel by the system or user, if required, and "n" means that the kernel does not provide support for the corresponding feature or driver. Because of the many configuration options in the kernel, this article only describes some of the more important options.

1. Code Maturity Level Options (coding maturity option)

Prompt for development and/or incomplete code/drivers (config_experimental) [n/y/?] If the user wants to use code or drivers that are still in the test phase, you can select Y. If you want to compile a stable kernel, select "N".

1. Processor type and features (processor type and features)

(1), Processor family (386, 486/cx486, 586/k5/5x86/6x86, PENTIUM/K6/TSC, PPRO/6X86MX) [PPRO/6X86MX] Select processor type, default = ppro/ 6x86mx.
(2), Maximum physical memory (1GB, 2GB) [1GB] The maximum number of memories supported by the kernel, the default is 1G.
(3), Math emulation (config_math_emulation) [n/y/?] coprocessor emulation, default is no emulation.
(4), MTRR (Memory Type Range Register) Support (CONFIG_MTRR) [n/y/?]

Select this option and the system will generate a/PROC/MTRR file to manage MTRR for use by x server.

(5), symmetric multi-processing Support (CONFIG_SMP) [y/n/?] Select "Y" and the kernel supports symmetric multiprocessor.

2. Loadable module support (can be loaded with modules)

(1), Enable loadable module Support (config_modules) [y/n/?] Select "Y" and the kernel supports loading modules.
(2), Kernel module loader (config_kmod) [n/y/?] Select "Y", the kernel will automatically load those loadable modules, otherwise users need to manually load.

3. General Setup (normal Setup)

(1), Networking Support (config_net) [y/n/?] This option sets whether the network supports are available in the kernel.
(2), PCI support (CONFIG_PCI) [y/n/?] This option sets whether PCI supports are available in the kernel.
(3), PCI access mode (BIOS, Direct, any) [any] This option sets the way Linux probes PCI devices. Select "BIOS", Linux will use the BIOS, select "Direct", Linux will not pass the BIOS, select "Any", Linux will directly detect the PCI device, if it fails, then use the BIOS.
(4) Parallel Port Support (config_parport) [n/y/m/?] Select "Y" and the kernel supports parallel ports.

4. Plug and Play configuration (Plug and Play device support)

(1), Plug and Play Support (CONFIG_PNP) [y/m/n/?] Select "Y" and the kernel will automatically configure the Plug and Play device.
(2), ISA Plug and Play Support (CONFIG_ISAPNP) [y/m/n/?] Select "Y" and the kernel will automatically configure the ISA bus-based Plug and Play device.
5, block devices (blocks equipment)

(1), Normal PC floppy disk support (CONFIG_BLK_DEV_FD) [y/m/n/?] Select "Y", and the kernel will provide the floppy.
(2), Enhanced Ide/mfm/rll disk/cdrom/tape/floppy Support (config_blk_dev_ide) [y/m/n/?] Select "Y", the kernel will provide the enhanced IDE hard disk, Support for CDROM and tape drives.

6. Networking Options (Network option)

(1), Packet socket (config_packet) [y/m/n/?] Select Y, and some applications will use the Packet protocol to communicate directly with the network device without passing through the other mediation protocols in the kernel.
(2), Network firewalls (config_firewall) [n/y/?] Select "Y" and the kernel will support the firewall.
(3), TCP/IP networking (config_inet) [y/n/?] Select "Y" and the kernel will support the TCP/IP protocol.
(4) The IPX protocol (CONFIG_IPX) [n/y/m/?] Select "Y" and the kernel will support the IPX protocol.
(5), Appletalk DDP (config_atalk) [n/y/m/?] Select "Y" and the kernel will support the Appletalk DDP protocol.

8. SCSI support (SCSI supported)

If the user wants to use a SCSI device, you can configure the appropriate option.

9. Network Device Support
Network device Support (config_netdevices) [y/n/?] Select "Y", and the kernel will provide supported networking drivers.
10, Ethernet (100Mbit) (10M or 100M Ethernet)

In this setting, the system provides a number of network card drivers, the user can only choose their own network card driver. In addition, users can add support for FDDI, PPP, slip, and Wireless LAN (Wireless LAN) to the kernel as needed.

11. Character devices (character device)

(1), virtual terminal (CONFIG_VT) [y/n/?] Select "Y" and the kernel will support the virtual terminal.
(2), support-Console on virtual terminal (config_vt_console) [y/n/?]
Select "Y" and the kernel can use a virtual terminal as the system console.
(3), standard/generic (dumb) serial Support (config_serial) [y/m/n/?]
Select "Y" and the kernel will support the serial port.

(4), support-Console on serial port (config_serial_console) [n/y/?]

Select "Y" and the kernel can use a serial port as the system console.

12. Mice (mouse)

PS/2 Mouse (aka "Auxiliary Device") support (Config_psmouse) [y/n/?] If the user is using a PS/2 mouse, this option should select "Y".

13. filesystems (File system)
(1), Quota Support (Config_quota) [n/y/?] Select "Y" and the kernel supports disk quotas.
(2), Kernel automounter Support (CONFIG_AUTOFS_FS) [y/m/n/?] Select "Y", the kernel will provide the Automounter to enable the system to automatically mount the remote file system at startup.
(3), DOS Fat FS Support (CONFIG_FAT_FS) [n/y/m/?] Select "Y", and the kernel supports the DOS FAT file system.
(4), ISO 9660 CDROM filesystem Support (CONFIG_ISO9660_FS) [y/m/n/?]
Select "Y" and the kernel will support the ISO 9660 CDROM file system.
(5), NTFS filesystem support (read only) (CONFIG_NTFS_FS) [n/y/m/?]
Select Y to enable the user to access the NTFS file system as read-only.

(6),/proc filesystem Support (CONFIG_PROC_FS) [y/n/?]/proc is a virtual file system that stores the running state of a Linux system, which must select "Y".

(7), Second extended FS Support (CONFIG_EXT2_FS) [y/m/n/?] EXT2 is a standard file system for Linux, which must also select "Y".

14. Network File Systems
(1), NFS filesystem Support (CONFIG_NFS_FS) [y/m/n/?] Select "Y" and the kernel supports NFS file system.
(2), SMB filesystem support (to mount WfW shares etc) (CONFIG_SMB_FS)
Select "Y" and the kernel will support the SMB file system.
(3), NCP filesystem support (to Mount NetWare volumes) (CONFIG_NCP_FS)
Select "Y" and the kernel will support the NCP file system.

15, Partition Types (partition type)

This option supports some less commonly used partition types, and if necessary, select "Y" on the appropriate option.
16. Console drivers (console driver)

VGA text Console (config_vga_console) [y/n/?] Select "Y" and the user can use Linux in the standard VGA display mode.

17. Sound (voice)

Sound card support (config_sound) [n/y/m/?] Selects "Y", and the kernel can provide the audio card.

18, Kernel hacking (kernel monitoring)

Magic sysrq Key (CONFIG_MAGIC_SYSRQ) [n/y/?] Select "Y" to allow the user to partially control the system. In general, select "N".

Four, compile the kernel

(i), build the required subordinate files at compile time

# Cd/usr/src/linux

# make DEP

(ii), clear the kernel compiled target file

# Make Clean

(c), compile the kernel

# Make Zimage

After the kernel compiles successfully, a new kernel image file Zimage is generated in the/usr/src/linux/arch/i386/boot directory. If the compiled kernel is large, you will be prompted to compile using the Make Bzimage command. At this point, the compiler generates a kernel image file called Bzimage.

(iv), compile loadable modules

If the user sets loadable modules when configuring the kernel, these modules need to be compiled for future loading with the Insmod command.

# Make Modules

# Make Modelus_install

After the compilation is successful, a 2.3.14 subdirectory is generated in the/lib/modules directory with all the loadable modules of the new kernel.

V. Start the new kernel

(i), copy the new kernel and System.map files to the/boot directory

# cp/usr/src/linux/arch/i386/boot/bzimage/boot/vmlinuz-2.3.14

# cp/usr/src/linux/system.map/boot/system.map-2.3.14

# Cd/boot

# rm-f System.map

# ln-s system.map-2.3.14 System.map

(b), configure the/etc/lilo.conf file. Add the following lines to the file:

default=linux-2.3.14

image=/boot/vmlinuz-2.3.14

label=linux-2.3.14

Root=/dev/hda1

Read-only

(iii) to make the new configuration effective

#/sbin/lilo

(iv), restart the system
#/sbin/reboot
If the new kernel does not start properly, the user can start the old kernel at the Lilo: prompt. Then find out the cause of the failure, recompile the new kernel.

Linux kernel compilation and parameter configuration

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.