Necessity and preparation for re-compiling Linux Kernel

Source: Internet
Author: User
The necessity and preparation for re-compiling the Linux kernel-Linux general technology-Linux programming and kernel information. The following is a detailed description. Linux Kernel version released on the official website is http://www.kernel.org, China's major ftp can generally find some versions of the kernel. The new version of the kernel is released in two forms: one is the complete kernel version, and the other is the patch file, that is, the patch. Compared with linux-2.4.0-test8.tar.bz2, the website has a large number of cores, which can be downloaded and used by users with fast network speeds. The internal kernel is generally a .tar.gz(.tgz.pdf file, which is a. bz2 file. The two files are compressed using gzip or bzip2, and need to be decompressed during use. Patch files are relatively small, generally only dozens of K to hundreds of K, and rarely exceed 1 M. Users with slow network speeds can use patch files to upgrade the kernel. However, the patch file is for a specific version. You need to find your own version to use it.

The root permission is required to compile the kernel. The following operations are assumed that you are the root user. Copy the kernel you want to upgrade to/usr/src/(the following uses linux-2.4.0test8.tar.gz of the kernel 2.4.0test8as an example). The command is:

# Cp linux-2.4.0test8.tar.gz/usr/src

Let's take a look at the current/usr/src content and notice that there is a linux Symbolic Link that points to a directory similar to a linux-2.2.14 (corresponding to the kernel version you are using now. First, delete the link:

# Cd/usr/src
# Rm-f linux

Decompress the downloaded source code file. If you download the .tar.gz (. tgz) file, use the following command:

# Tar-xzvf linux-2.4.0test8.tar.gz

If you download the. bz2 file, for example, linux-2.4.0test8.tar.bz2, run the following command:

# Bzip2-d linux-2.4.0test8.tar.bz2
# Tar-xvf linux.2.4.0.test8.tar

Now let's take a look at the content under/usr/src. Now you will find that there is a directory named linux, which contains the source program of the kernel we need to upgrade. Do you still remember the link named linux? The reason for using that link is to prevent the source program of the original kernel version from being overwritten during kernel upgrade. We also need to handle the same problem:

# Mv linux linux-2.4.0test8
# Ln-s linux-2.4.0test8 linux

In this way, we also have a symbolic link named linux, so you don't have to worry about overwriting it in the future (maybe you will feel that it is unnecessary to re-establish a linux Symbolic Link, but in fact this is essential, which will be introduced below ). If you also download the patch file, such as the patch-2.4.0test8, you can perform the patch operation (assuming that the patch-2.4.0test8 is already in the/usr/src directory, otherwise, you need to copy the file to/usr/src first ):

# Patch-p0 <patch-2.4.0test8

Now, we have upgraded the kernel source program to the latest version.

Preparations

The first command to be run is:

# Cd/usr/src/linux; make mrproper

This command ensures that the source code directory does not contain the correct. o file and file dependencies. This step can be omitted because we use the downloaded full source program package for compilation. If you use these source programs to compile the kernel multiple times, you 'd better run this command first.

Make sure that the asm, linux, and scsi links in the/usr/include/directory point to the source code of the kernel to be upgraded. They chain the real include sub-directories required by the real computer architecture (i386 for PCs) under the source code directory. For example, asm points to/usr/src/linux/include/asm-i386 and so on. If you do not have these links, you must create them manually. follow these steps:

# Cd/usr/include/
# Rm-r asm linux scsi
# Ln-s/usr/src/linux/include/asm-i386 asm
# Ln-s/usr/src/linux/include/linux
# Ln-s/usr/src/linux/include/scsi

This is an important part of configuration. Delete the asm, linux, and scsi links under/usr/include, and then create a new link pointing to the directory with the same name under the new kernel source code directory. These header file directories contain the important header files required to ensure that the kernel is correctly compiled on the system. Now you should understand why we have created a link named linux in the "redundant" Directory of/usr/src? Next we can start the kernel compilation journey.

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.