Compile the kernel under mongout-general Linux technology-Linux programming and kernel information. The following is a detailed description. Step 1:
Download the latest (or the Linux kernel source code you want)
: Www.kernel.org
You can run the uname-a command to check the kernel version and compile time of the current system.
After obtaining the source code, decompress it to a directory.
We recommend that you decompress the package ~ In the/linux/directory, let me know why.
Step 2:
Open the terminal and enter the source code directory, for example:
Cd ~ /Linux/linux-2.6.20.1/
Make mrproper first for security reasons,
To clear all the configuration files in the Directory and the intermediate files generated when the previous kernel is generated.
Next we will perform Kernel configuration, which is the most difficult and critical step.
There are four ways to do this:
# Make config
# Make menuconfig
# Make xconfig
# Make oldconfig
I am using the second method, but now the problem arises. An error occurs after running the command, and a bunch
The most critical error message is that one library is missing.
In the past, many things were missing during Ubuntu installation, especially for programming. You need to install them through the "Source ".
The so-called "Source" is not clear. It is probably equivalent to an online Windows Upgrade Program.
Ubuntu does not have all its own sources, but its speed is slow. Some of them cannot be connected, so you need to add some sources by yourself.
After setting the source, you can install the required items online.
Here, I would like to remind my friends who use Ubuntu:
When the source is automatically updated for the first time, the input method in Ubuntu is also updated.
However, this update is not compatible with the previous version. Therefore, the input method cannot be used.
I was depressed for half a day and found a solution after I went online for a long time:
The -- initrd must be required. Otherwise, the initrd file cannot be generated.
-- Append: multiple images are generated, that is, the options shown in the Start Menu.
Wing1 is the name of your own image
After the kernel is numbered, the last two items of the linux-2.6.20.1-custom are generated mirror package and header package displayed
After make is complete, two deb packages are displayed in the previous directory.
Use the dpkg-I command to install the two packages.
Install the kernel and header package
Sudo dpkg-I linux-image-2.6.22.1-2.6.22.1_2.6.22.1-2.6.22.1-10.00.Custom_i386.deb
Sudo dpkg-I linux-headers-2.6.22.1-2.6.22.1_2.6.22.1-2.6.22.1-10.00.Custom_i386.deb
After this process is completed, a new startup Item is automatically added to/boot/grub/menu. lst, which is convenient without manual modification.
Restart to enter the new kernel. This method is also applicable to debian, and ubuntu is much easier than the traditional method.
At this time, everything is done.
You can check whether the Vmlinuz, initrd, and System. map files are in the/boot directory.
Then check whether the content in the/boot/Grub/menulist file has been added to your newly compiled kernel.
If yes, congratulations, please feel free to restart.
After the restart, you can enter your own compiled kernel.
Compile the kernel in Normal Mode:
1. Install the necessary toolkit
Includes: libncurses5-dev (required by menuconfig) and essential
Sudo aptitude install build-essential bin86 kernel-package
Sudo aptitude install libqt3-headers libqt3-mt-dev
Sudo aptitude install make
Sudo aptitude install gcc // it is best to update the gcc even if it has been installed.
In addition, enter sudo mki on the terminal and press "Tab" twice to check whether the terminal displays
Mkinitramfs mkisofs
These two tools are used to generate *. imgfile during kernel compilation. If not, install them.
Step 2 download the kernel
Download the new kernel to www.kernel.org. The latest kernel is linux-2.6.21.1.tar.bz2 (the kernel of the original system is 2.6.20-15-generic. If you use the Nvadia acceleration driver, use the Source in the Source, otherwise it may fail to start X)
Step 3 preparations before Compilation
View the current kernel version
Uname-
2.6.15-26-server
If the downloaded kernel version is the same as the current kernel version:
Cd/lib/modules
Rename the folder under it
At the same time, you need to modify some items under/boot, and then modify/boot/grub/menu. lst.
It is troublesome. It is recommended to download a kernel higher than the current installed version.
Extract the linux-2.6.16.2 folder from linux-2.6.21.1.tar.bz2 and put it under/usr/src.
Sudo ln-s linux-2.6.21.1 linux // If the folder already has a link named linux, change it to linux. old first
Step 4 start Compilation
Cd/usr/src/linux // all the following work is completed in/usr/src/linux
Sudo make mrproper // remove. o compiled files
Sudo make menuconfig // If menuconfig is used, two other toolkit support is required. What is the name I forgot, Ncurses? Or use
Sudo make xconfig
Next, you can configure it slowly and save it after configuration. (The Kernel configuration file saved in the system is named in/usr/src/linux. config, you can save another copy in another place)
Sudo make dep // The system may prompt that make dep is not necessary now, so proceed to the next step.
Sudo make clean // clear old data
Sudo make bzImage // compile the kernel. bzImage is the name you give to the new kernel and will be saved to/usr/src/linux/arch/i386/boot /.
Sudo make modules // compilation Module
Sudo make bzImage install // install the kernel
Sudo make modules_install // installation Module
Sudo mkinitramfs-o/boot/initrd. img-2.6.21.1 2.6.21.1
After the installation is complete, add the following files under/boot (use ls-l to view the files)
Lrwxrwxrwx 1 root 15 config-> config-2.6.21.1
-Rw-r -- 1 root 71023 config-2.6.21.1
-Rw-r -- 1 root 39445347 initrd. img-2.6.21.1
Lrwxrwxrwx 1 root 19 System. map-> System. map-2.6.21.1
-Rw-r -- 1 root 795827 System. map-2.6.21.1
Lrwxrwxrwx 1 root 16 vmlinuz-> vmlinuz-2.6.21.1
-Rw-r -- 1 root 1703296 vmlinuz-2.6.21.1
Add a new startup Item:
Sudo vim/boot/grub/menu. lst
Title Ubuntu, kernel 2.6.21.1
Root (hd1, 0) // note the partition name
Kernel/boot/vmlinuz-2.6.21.1 root =/dev/sdb1 ro
Initrd/boot/initrd. img-2.6.21.1
Boot
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