Linux Recompile kernel Guide

Source: Internet
Author: User

An important feature of Linux is the openness of its source code, and any software engineer in the world can add the code that they think is good, and the obvious benefit is the fast Linux patching and the use of the latest software technology. The kernel of Linux is the most direct representation of these features.
  
Why upgrade the kernel
  
As the literal meaning of its name implies, the Linux kernel assumes the most central task of the Linux operating system and is the arbiter of other programs and hardware: it manages the memory of all processes, ensuring that they all have equal access to the processor's timeslot. In addition, it provides features such as interfaces between programs and hardware.
  
In general, the updated kernel will support more hardware, better process management, faster and more stable, and generally repair many of the vulnerabilities found in the old version, and regularly choose to upgrade the updated system kernel is the necessary operation of Linux users.
  
In general, the kernel version serial number is represented by three digits, such as 2.2.14, the higher the version number, the more powerful the function. Version number is divided into two series: one is the product line, with even name, for example, 1.2.x, 2.0.x, 2.2.x, etc., run stable, has been more thorough testing; another is the development of Test series, named after the odd, for the latest features of the test, not recommended for beginners and production process use.
  
In the later part of this article, the upgrade process of kernel 2.0.34 to 2.2.14 is described in the steps, concepts, considerations, and more documents that can be referenced in the kernel upgrade, and the italicized words appearing in the text are direct input commands.
  
Configuration and compilation of the kernel
  
The types of CPUs currently supported by Linux include x86, ARM, DEC Alpha, SUN Sparc, M68000, MIPS, PowerPC, and so on, which should be said to include the majority of the CPU models used by the user. These models are automatically recognized by Linux during the installation and configuration process.
  
The first command that you typically run is: #cd/usr/src/linux;make mrproper. Make sure the source code directory does not have an incorrect. o file and the interdependence of the files.
  
The next kernel configuration process is cumbersome, but the appropriateness of the configuration is directly related to the future operation of Linux, and it is necessary to understand some of the major and frequently used options settings.
  
Configure the kernel to use one of the following commands, as needed and as a hobby:
  
#make Config (the most traditional text-based configuration Interface)
  
#make menuconfig (Text menu-based configuration Interface)
  
#make xconfig (Configuration interface based on graphics window mode)
  
#make Oldconfig (if you just want to modify some small places on the basis of the original kernel configuration, it will save a lot of trouble)
  
When configured, most options can use their default values, and only a small number of them need to be selected depending on the user's needs. For example, if you need a file system with a DOS partition supported by the kernel, you should select FAT or DOS system support in the File System section, and if you have a network card, PCMCIA card, etc., you need to select the appropriate card type in the configuration.
  
When selecting the appropriate configuration, there are three options, each of which represents the following meanings:
  
"Y"-compiles the function into the kernel
  
"N"-does not compile the function into the kernel
  
"M"-compiles this function into a module that can be dynamically inserted into the kernel when needed.
  
Compiling part of the function code that is far away from the rest of the core and infrequently used is a loadable module that reduces the length of the kernel, reduces the memory consumed by the kernel, and simplifies the effect on the kernel when the corresponding environment changes for that function. Many features can be handled like this, such as the support for the network card mentioned above, and the support for file systems such as FAT.

After configuring the kernel, you need to verify the dependencies and integrity of the kernel source code files, and compile them to ensure that the GCC version used by the system is above gcc-2.7.2:
  
#make DEP (ensure critical files are in the correct location)
  
#make Clean (make sure all relevant files are in the latest version state)
  
#make Zimage (kernel compiled in compressed form)
  
When you need the kernel to support more peripherals and features, the kernel may become large, and you can compile a large kernel:
  
#make Bzimage
  
Compile time and the hardware conditions of the machine and the configuration of the kernel and other factors, with the author of the 64MB memory Celeron 300 For example, compile the kernel once roughly more than 20 minutes. The location of the obtained kernel is in the/usr/src/linux/arch/i386/boot directory, assuming that the user's CPU is x86 type.
  
If a loadable module is selected and the kernel is compiled, the selected module is compiled:
  
#make Module (compilation of selected modules)
  
#make Module-install (Transfer the compiled module to the system standard location)
  
The standard directory of modules in the system is located in/lib/modules/x.y.z, and the latter x.y.z is the version number, and for security reasons it is best to back up/lib/modules before running #make Modules-install. The module is usually a file with the extension. O, using the command #lsmod to list the modules of the current kernel.
  
Software downloads and unpacking
  
Select a relatively fast and authoritative site to download the latest kernel source packages, for example, if conditions permit, to download the following sites:
  
Ftp://sunsite.unc.edu/pub/linux/kernel
  
Domestic Linux users can download to the following sites:
  
http://studio.openunix.org
  
Http://www.clinuxworld.com
  
Note that if the upgrade version has a large span and is expected to be configured with an external module, the latest module tool modules-x.y.z.tar.gz is also downloaded.
  
The core code of the Linux system is stored in the directory/usr/src/linux, which, in fact, is a link to the directory of the core version currently in use, for example, if the current version is 2.0.34, the actual directory for that core should be:/usr/src/ linux-2.0.34. The directory in the newly downloaded kernel is Linux, so that unpacking directly under/USR/SRC causes the original kernel directory to be overwritten. So it's a safe practice to remove the link Linux first, then unpack, rename, and Relink.
  
Before unpacking, verify that there are no directories called Linux in the/USR/SRC directory, or that you no longer want to keep the directory.
  
In addition, as the Linux kernel functions and support for more peripherals, the file package is also more and more, the current stable version of the 2.2.14 core compression package size is about 14MB, but in fact, the decompression and compilation, and so on, requires the/USR/SRC directory is located in the partition of more than 60MB bytes of free space.
  
Enable new kernel
  
Copy the compiled new kernel to the system directory/boot, for example
  
#cp/usr/src/linux/arch/i386/boot/zimage/boot/zimage-2.2.14
  
Then, edit the system boot configuration file/etc/ Lilo.conf, follow the original option to add a new kernel option, give it a distinctly memorable label, remember that it is better to keep the original kernel and the corresponding options, so as not to fear the upgrade failed and the machine can not boot, at least also use the old kernel to boot their own computer. When you save your edits and exit, remember to run the command: #lilo, update the system boot image so that changes to lilo.conf will work.
  
After restarting the machine, press the TAB key at Lilo's prompt and you should see the new kernel option added.
  
For the current domestic Linux version after the Chinese, because a few of the major versions are in the kernel, such as surfing platform Xteam Linux, Blue dot Bluepoint Linux, etc. Therefore, users who use these distributions should follow the above steps to upgrade the kernel, which will result in the failure of Chinese and the unstable operation of the system. Users need to wait for the manufacturers to release the new kernel of the Chinese package, and then to the manufacturer designated download site download, follow the instructions to upgrade.

Linux Recompile kernel Guide

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.