Patch the kernel source code (optional)
Sometimes your default kernel does not support new devices. You need to install a new driver. or you need to use virtual technologies or other advanced technologies, which are not supported by these existing kernels. in this case, you need to patch the kernel source code (of course the patch has been released ..)
Now, let us assume that you have downloaded the patch (in the following example, we call patch.bz2) to/usr/src. Run the following command to directly patch the kernel source code (your user must be in the/usr/src/Linux directory ):
bzip2 -dc /usr/src/patch.bz2 | patch -p1 --dry-runbzip2 -dc /usr/src/patch.bz2 | patch -p1 |
The first command is used for testing and has no impact on the kernel. If no error is displayed, you can run the second command to patch the kernel. If the first command is incorrect, proceed with this operation!
You can also install patches through kernel prepatches. for example, if you need a feature that is only available in 2.6.19-RC4, the official complete kernel version is not yet released, and the patch-2.6.19-rc4.biz2 has been released. you can call this patch to the kernel source code of 2.6.18, but do not set it to 2.6.18.1 or 2.6.18.2. this rule will be noted on the following webpage: http://kernel.org/patchtypes/pre.html.prepatchesand so on. They are located in the test directory of the archive, and we can use patch (1) tool for the previous full release (version number is divided into three) patch (for example, 2.6.12-RC4 prepatch can only patch 2.6.11 kernel source code, rather than 2.6.11.10 .)
So if you want to compile 2.6.19-RC4 kernel, you must download 2.6.18 (http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2) in Step 3.1 to replace 2.6.18.1 kernel source code!
The following describes how to patch 2.6.18 with 2.6.19-RC4:
cd /usr/srcwget http://www.kernel.org/pub/linux/kernel/v2.6/testing/patch-2.6.19-rc4.bz2cd /usr/src/linuxbzip2 -dc /usr/src/patch-2.6.19-rc4.bz2 | patch -p1 --dry-runbzip2 -dc /usr/src/patch-2.6.19-rc4.bz2 | patch -p1 |
5. Configure the kernel
It is a good idea to use the current working Kernel configuration file as the basis for the new Kernel configuration file. therefore, copy the saved configuration file to/usr/src/Linux: CP/boot/config-'uname-R '. /. config. Run: Make menuconfig
Then we can see the Kernel configuration menu. Move the green cursor to the load an alternate configuration file line and select the. config file (including the configuration of the current working kernel) as the configuration file.
Then, go to the Kernel configuration menu and select the desired function. After completing the configuration, select exit and answer the following question (Do you wish to save your new Kernel configuration? Do you want to save the new Kernel configuration ?), Select Yes:
6. Build the kernel
Run the following command to build the kernel:
make-kpkg cleanfakeroot make-kpkg --initrd --append-to-version=-custom kernel_imagekernel_headers |
After -- append-to-version =, you can write any string to differentiate the kernel version, but it must start with the "-" symbol without any spaces.
It takes some time to compile the kernel. It mainly depends on your Kernel configuration and processor speed.
7. Install the new kernel
After the kernel is successfully built, you can find two. Deb packages in the/usr/src directory.
On my testing system, they were named linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb (containing the actual kernel) and linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb (containing the files needed for later compilation of additional kernel modules ). I installed it like this:
dpkg -i linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.debdpkg -i linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb |
Source: exam big-Linux Certification Exam
Address: http://www.examda.com/linux/fudao/20061204/093122234-2.html