Compile the kernel in mongout

Source: Internet
Author: User
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:

Sudo apt-get remove fcitx
Rm-R ~ /. Fcitx
Sudo apt-get install fcitx

It is to remove the original fcitx input method from its configuration file in the root directory (? It seems to be), and then reinstall

OK. Let's get down to the point. To compile the kernel, you need the following:

Apt-get install libncurses5-dev (meke menuconfig to call)

Apt-get install libqt3-headers (make xconfig to call)

The list above is incomplete, but the source will prompt you when you install it. Which packages are recommended for installation?

Install them all.

If there is no basic programming library (gcc, make, etc.)

Apt-get install build-essential

If everything above is installed, congratulations, you can make menuconfig.

But don't worry. I believe your current system is working very well.

Surfing the Internet, voice, display... no problems

But after you re-compile the kernel, you may have less things, for example, you may not be able to get on the Internet or get lost.

Even serious systems cannot be connected.

For this reason, you 'd better copy the. config file used by the current kernel as a template.

After you make menuconfig, select the second-to-last item: load config (it seems like this name is not clear)

Load. config, so that you can modify it based on the original kernel.

At this time, I believe you don't just need to subtract anything.

It's just as easy to use after compiling the kernel.

What do countless options in menuconfig mean?

I believe you cannot understand English.

I found an option on the Internet and sent it to the Forum.

Later I found that Huang Cheng had a more comprehensive experience. It was really brilliant.

However, there is an option that is rarely mentioned, that is, if you find that

No progress bar at restart

Most of the reason is that you have

CONFIG_FRAMEBUFFER_CONSOLE, not M (dynamic loading), but X (compiled into the kernel)

By the way, if you have this problem, find it.



After configuration, we strongly recommend that you back up the generated. config file.

In this way, what problems will happen in the future?

You can copy the file right away.


Step 3:
The next step is simple.

If your character is good enough, the following four commands will be OK:

Make clean

Make-j4 (-j4 divides the processor into four threads to compile the kernel, which is fast and recommended for good CPU usage)

Make modules_install

Make install

After the kernel is restarted, you can view the new kernel on the boot menu.

I'm not good enough, or Ubuntu is too different.

Don't generate an initrd file for me

The following command is used for online query:

Make-kpkg clean (what is kpkg)

Make-kpkg -- initrd -- append-to-version =-custom kernel_image kernel_headers

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

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.