Build a Linux kernel tree
Reprinted from: http://hi.baidu.com/wdr_cloud/item/a101178d02f5d6934514cf57
The following content is for personal learning only. Do not use it.
First, check the kernel version used by your OS.
Shana @ Shana :~ $ Uname-R
2.6.22-14-generic/* this is the result of my display */
If the source code is automatically installed during system installation. There is a corresponding version directory under the/usr/src directory. Example)
Shana @ Shana:/usr/src $ ls
Linux-headers-2.6.22-14
Linux-headers-2.6.22-14-generic
Linux-source-2.6.22/* This is the decompressed source directory */
Linux-source-2.6.22.tar.bz2/* this is my source package */
Shana @ Shana:/usr/src $
If no source code is available. (Not UBUNTU)
Check the downloadable source code package (remember not to use this command by a Super User, otherwise ...... This command is not displayed)
Shana @ Shana:/usr/src $ apt-cache search Linux-Source
Linux-source-Linux kernel source with Ubuntu Patches
Xen-source-2.6.16-Linux kernel source for version 2.6.17 with Ubuntu Patches
Linux-source-2.6.22-Linux kernel source for version 2.6.22 with Ubuntu Patches
Shana @ Shana:/usr/src $
I chose linux-source-2.6.22-Linux kernel source for version 2.6.22 with Ubuntu patches this ~
Then install
Shana @ Shana:/usr/src $ sudo apt-Get install linux-source-2.6.22
After the download is complete, under/usr/src, the file name is: linux-source-2.6.22.tar.bz2, is a compressed package, extract can get the entire KernelSource code:
Note that the superuser mode has been switched.
Root @ Shana:/usr/src # tar jxvf linux-source-2.6.20.tar.bz2
Decompress the package and generate a new directory/usr/src/linux-source-2.6.22 for all the sourcesCodeAll in this directory.
Enter this directory
Start to configure the kernel and select the fastest original configuration (default) method (I do)
Root @ Shana:/usr/src/linux-source-2.6.22 # Make oldconfig
Of course, you can also use your favorite configuration methods such as menuconfig and xconfig (you must have a GTK environment ). You don't need to crop anything, so you can configure it in any way.
After that, start to make it. Generally, it takes an hour. (Ensure that the space is sufficient. I used 1.8 GB after compilation.) I gave the/directory 30 GB space for the partition. I did not encounter this problem. My friend met me.
Shana @ Shana:/usr/src/linux-source-2.6.22 $ make
Shana @ Shana:/usr/src/linux-source-2.6.22 $ make bzimage
Of course, the first make statement can also be executed without making bzimage directly. After the execution is complete, a new file named vmlinux is generated in the current directory. Its attribute is-rwxr-XR-X.
Then:
Root @ Shana:/usr/src/linux-source-2.6.22 # Make modules/* Compilation module */
Root @ Shana:/usr/src/linux-source-2.6.22 # Make modules_install/* installation module */
After the execution, a new directory/lib/modules/2.6.22-14-generic/will be generated under/lib/modules/
. The build directory under this path will be used for subsequent compilation of module files. So far, the kernel compilation is complete. You can restart the system.