Linux Kernel compilation learning notes

Source: Internet
Author: User

Linux Kernel compilation learning notes

Author: laomai

Home: http://blog.csdn.net/laomai

I. experiment environment
An industrial computer with an optical drive. The RedHat Linux ES3 operating system is installed. Minimum installation,
That is, when selecting software, you do not select anything.

References:
Http://www.uplinux.com/www/sys/01/77.shtml
Http://tristones.viaspeip.com/archives/000209.html
 
2. view the current system configuration
1. view the kernel version number
# Uname-
2. view the mounted modules.
# Lsmod

3. Install the tools required for compilation (GCC, make, and ncurse)
Cpp-3.2.3-20.i386.rpm
Glibc-devel-2.3.2-95.3.i386.rpm
Glibc-headers-2.3.2-95.3.i386.rpm
Glibc-kernheaders-2.4-8.34.i386.rpm
Gcc-3.2.3-20.i386.rpm
Make-3.79.1-17.i386.rpm
Ncurses-devel-5.3-9.3.i386.rpm

Iii. Preparations before Compilation
1. Obtain the kernel source code. There are several methods
(1) I used as3 third installation CD kernel-source-2.4.21-4.EL.i386.rpm.
(2) download the latest kernel version to http://www.kernel.org/
 
2. Install the kernel code
Rpm-IVH kernel-source-2.4.21-4.EL.i386.rpm
3. Clear the things left during previous kernel Compilation
CD/usr/src/linux-2.4 # Enter the directory where the kernel source code is located
Make mrproper # clean up

4. Set kernel options
Run # Make menuconfig
1. Options
After you execute make menuconfig, a main menu is displayed, and you can use the arrow keys to select a menu item. If you select an item with a sub menu (ended with "--> ), press enter to go back to the sub-menu.
Option configuration format:
Press Y to include the options in build-in mode, that is, to integrate the options into the kernel.
The corresponding icon is [*] or <*>,
Press n to indicate that it does not contain. The corresponding icon is [] or <>
In M format, it is included in the form of a module, and the corresponding icon is <m>. Note that not all options can be loaded in the form of a module.

2. Option status icon
After each option is set, a status icon is displayed, which can only be one of the following five
[*]-Built-in indicates that this option is integrated into the kernel.
[]-Excluded indicates that this option is excluded from the kernel.
<M>-module indicates that this option is placed in the kernel as a module,
You need to execute the insmod command when using this option.
Note that not all options can be loaded as modules.
So when you press the M key and the icon is still [*] instead of <m>
Understand that this option can only be integrated in the kernel or excluded by the kernel.
<>-Module capable indicates that this option is excluded,
It can be reloaded as a module. For example, a <m> icon
After you press the n key, the status changes to <>.
<*>-This icon is not written, and will appear in actual cases. For example, the status of an option is <m>
Or <> press the y key to convert the icon into this, which means the module can be used in the same way [*].
The loaded option is changed to build-in mode.

To sum up, this option is not loaded if it is blank in parentheses;
If * is in the brackets, it is loaded in build-in mode;
If the center is m (at this time, it can only be angle brackets), it is dynamically loaded in the form of a module.

3. Meanings of options
You can press the H key to get help on the meaning of each specific option. The main purpose of this article is to clarify the experiment steps,
The default value is used for all options.
4. Save settings
After the required options are set, Press ESC to exit menuconfig. The system will prompt whether to save the settings. Select Yes.

5. Start Compilation
1. Set the associated file
# Make Dep
2. Compile the kernel (that is, compile the build-in stuff). It takes about 10 minutes for my machine (4 + 512 memory)
# Make bzimage
3. Compile the module for a long time. It took me about one hour.
# Make clean
# Make modules
4. Installation Module
# Make modules_install
5. Check Results
# Depmod-
Check whether there is any unresolved symbol in the kernel. It is the dependency between the generated modules,
After the new kernel is started, the module can be correctly located when The modprobe command is used to load the module.
If no information is returned after you enter this command, the compilation process is successful.

6. Install the complete new kernel
# Make install

6. Start with a new kernel
1. Check the/etc/Lilo. conf file.
We can see that the newly compiled kernel has been added to the boot menu.
2. Execute/sbin/lilo to make the new startup settings take effect.
3. Restart the machine and watch the Startup menu. If one more item is added, it indicates that it is successful!

 

VII. Thank you

In the course of learning and compiling the kernel, I got some advice and help from the friends of crystal Jianfeng, knife, benzene bear, and xiao'er.

Thank you.
 

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.