Linux configuration and kernel Compilation

Source: Internet
Author: User
Tags apm
Article Title: Linux Kernel configuration and compilation. 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.
The compiling kernel contains two main items: Configuring the kernel and compiling the kernel. You need to frequently view the kernel Documentation for these two tasks. You must at least view the Changes files in the Readme file and Documentation directory. They describe the kernel, such as problems that may occur during kernel upgrade and kernel version requirements for tools in the system. The Linux kernel compilation method is described below.
  
   Download and decompress
First, download the kernel source code to the/usr/src/directory. If the compression format is gzip, run the following command:
  
# Tar xzvf linux-2.4.23.tar.gz
  
If the format is bzip2, run the following command:
  
# Tar xjvf linux-2.4.23.tar.bz2
  
The Linux-2.4.23 kernel source code tree is created. Go to this directory and make sure that all future operations are completed in this directory.
  
   Configure the kernel
With the kernel to be compiled and configured, we will first introduce how to configure the kernel. The specific steps are as follows:
  
1. Before starting to configure the kernel, run the following command to clear all the temporary files, middleware, and configuration files. For a kernel just downloaded from the internet, it must be clean. But this is a good habit and there will be no bad results.
  
# Make mrproper
  
2. Then you need to know the hardware configuration of your system, such as the CPU type, host chip, video card and sound card model.
  
3. Run the following command to configure the kernel options:
  
# Make
  
   The following configuration tools are used:
◆ Config is based on the interactive text configuration interface. Each question appears in a linear format and is answered one by one. Once an answer is made, it cannot be modified.
  
◆ Oldconfig is similar to config, but the original configuration file is used, and only questions about new kernel features are asked, which is convenient for Kernel upgrade.
  
◆ Menuconfig: a text mode and menu driver configuration interface.
  
◆ Xconfig is based on the X graphical configuration interface of Tcl/Tk.
  
Now start to configure the kernel. The tool used is menuconfig. Run the following command in command line mode:
  
# Make menuconfig
  
After several lines of text are flashed, the interface shown in 1 is displayed.
  
   Kernel configuration interface
  
Use the arrow keys to move between options. Use the "Enter" key to Enter the next menu. The highlighted letters on each option are keyboard shortcuts, you can use it to quickly get to the menu items you want to set. Press "y" in brackets to compile the project into the kernel, and press "m" to compile the project as a module, press "n" for no selection (you can also switch between compiling into the kernel, compiling as a module, and not compiling by pressing the Space key ), press "h" to display the help information for this option. Press "Esc" to return to the upper menu.
  
Note: If the "make menuconfig" command fails, it is likely that the ncurses library is not installed.
  
There are many Kernel configuration options. Here we will briefly describe the main options so that you can customize the kernel according to your own situation. If you are unsure of some items, you can refer to the documentation/Configure. help file, or search the entire system and check the files in which the related options appear. The following describes the configuration of an option.
  
◆ Loadable module support (supported modules can be loaded ). The "Enable loadable module support" option allows the kernel to support modules. The "Module unloading" option allows you to detach modules that are no longer in use. If you do not select this option, you cannot detach any modules. (Note, some modules cannot be detached Once loaded, regardless of whether this option is selected.) The "Module versioning support (EXPERIMENTAL)" option allows users to use the modules compiled in other versions of the kernel, but it is not reliable, so it is generally not selected; the "Automatic kernel module loading" option allows the kernel to automatically call the "modprobe" command to load the required module.
  
A module is a small piece of code. After compilation, it can be dynamically added to the kernel during system kernel running, so as to add some features to the kernel or support certain hardware. Generally, some commonly used drivers or features can be compiled as modules to reduce the size of the kernel. You can run the "modprobe" command to load the module to the kernel (you can uninstall it when you don't need it ).
  
◆ Set version infomation on all symbols for modules (CONFIG_MODVERSIONS) is an option for kernel module version control. If you want to develop the kernel module code (including any module code other than the current kernel source code tree), enable this setting. Generally, you can disable it.
  
◆ (Pentium-III/celon (Coppermine) Processor family is used to select the CPU type. It allows the kernel to use special commands inside the advanced processor. Of course, if the user's CPU is 80386, there is no need to select P4. However, if you do not know how to choose, select 386. In this case, if you use an advanced CPU, the kernel runs slowly than it should, but at least it can run. We recommend that you use Help and/proc/cpuinfo for more Help.
  
◆ High Memory Support (CONFIG_NOHIGHMEM) enables the kernel to Support large Memory. Generally, the kernel only supports 1 GB of memory (the actual situation is 896 MB, which is related to the implementation of vmalloc (), which is beyond our scope of discussion ). If the user's memory size exceeds 896 MB, select 4 GB memory support for the kernel, or even 64 GB memory support.
  
◆ Using Ric multi-processing support (CONFIG_SMP) enables the kernel to support multi-processor. If you have more than one CPU, You must select this one.
  
◆ Maximum number of CPUs (2-32) is used to select the number of processors. It makes no sense to select the number of CPU users.
  
◆ General setup indicates General configuration. Here, we can set Kernel support for virtual memory and provide a communication mechanism for System V processes. Some core parameters and variables can be dynamically changed using the "Sysctl support" option, you do not need to restart the system.
  
◆ File systems (File System ). There is a lot of content here. We recommend that you modify the content based on the default value. Generally, dos fat (FAT16, FAT32), VFAT, EXT3, NTFS, and ISO9660 (file system used on the standard CD) are required.
  
This section describes the main options of these kernel configurations. After you configure the kernel as required, you need to compile the kernel.
  
◆ Power management options (ACPI, APM) is an advanced Power management service. Note that ACPI and APM cannot be used at the same time. If both are configured, APM is disabled and ACPI is loaded if a working ACPI device is found during system startup.
  
If you want Linux to support advanced Power Management, such as soft shutdown and System sleep, you need to select the "Power Management support" option; "Software Suspend (EXPERIMENTAL) "option can be used to suspend a computer (similar to sleep in Windows XP), which does not require support for advanced power management. The" Processor "option allows the Processor to save power during idle time and should be selected; when the system temperature is too high, the "Thermal Zone" option promptly adjusts the operating status of the system to protect the CPU (hardware support is required ).
  
◆ Bus options (PCI, PCMCIA, EISA, MCA, and ISA) are used to set the system Bus. Choose your own Based on the motherboard parameters. The "PCI support" option is available for the PCI bus, and the ISA and EISA sub-items are listed below, which are generally required. The "Support for hot-pluggable devices" option is for hot swapping devices; the "PCMCIA/carw.support" option supports PCMCIA.
  
◆ Executable file formats indicates the format of the Executable file, which should be selected in general.
  
◆ Device Drivers is used to select the Device driver. Choose sound cards, graphics cards, NICS, and video cards. Among them, the "Plug and Play support" option supports Plug-and-Play; the "Block devices" option supports Block devices; and the "SCSI device support" option supports SCSI devices; the "Multi-device support (RAID and LVM)" option supports RAID and logical volumes; the "Networking support" option supports networks, including network protocols and network devices, the protocol must be set to "TCP/IP" and select the corresponding device based on the network adapter. The "ISDN subsystem" option must be selected for ISDN Internet access. The "Sound" option is a Sound card driver, there are two options: the ALSA driver and the Open Sound System driver. Select the one that supports your own Sound card and compile it into the kernel; the "USB Support" option is very important. USB is usually used as a USB device. for USB, at least "Support for USB", "USB device filesystem ", "Echi hcd (USB 2.0) support", "uchi hcd (most Intel and) support, USB Audio support, usb midi support, and USB Mass Storage support options.
  
After "make" is executed, the system will generate an autoconf. h file in the include/linux directory. For example, when you configure the kernel option to support the NTFS file system and compile it into the kernel. "CONFIG_NTFS_FS = y" will be generated in config, corresponding to include/linux/autoconf. "# define CONFIG_NTFS_FS 1" is generated in h. Therefore, all C source files related to the NTFS file system will contain the include/config/ntfs/fs. h header file.
  
Two GUI configuration tools are added to the new 2.6.0 kernel. To use xconfig, you must first install the Qt Library (usually available on the CD-Rom of the release version). To use gconfig, you must first install the Gtk library.
  
When the configuration tool is started, the 2.6.0 kernel reads the current system configuration to maintain the same options as the current configuration. This feature is convenient for future upgrades. When the kernel features do not change much, it can be directly based on the current options, saving the trouble of configuration item by item. There are two ways to enable the configuration tool with the default options in the 2.6.0 kernel, one is to delete the current configuration file/boot/config-XXX; the other is to execute the "make defconfig" command before executing the Configuration tool.
  
In addition, several new options are added for make, including allyesconfig, allnoconfig, and allmodconfig. They are prepared for Kernel developers and testers.
  
After you configure the kernel according to your requirements, compile the kernel.
  
   Compile the kernel
The software environment for compiling the kernel is the kbuild system. It refers to all the resources required to build a complete and runable Linux kernel. These resources include build programs, scripts, middleware, configuration files, and makefiles. The following describes how to compile the kernel:
  
1. "make dep" or "make depend"
  
Kbuild calls the middleware scripts/mkdep to generate the dependency between the description and related core files.
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.