How to compile the kernel module?

Source: Internet
Author: User

Most programmers are studying kernel module compilation. In today's society, Linux is becoming more and more popular. Are you the application of Linux? This article describes kernel module compilation in detail, which plays a certain role in learning kernel module compilation.

1. Enter the new kernel source code directory

# Cd/usr/src/kernels/linux-2.6.26.2

2. Generate a configuration file during the read configuration process and create a dependency tree corresponding to the configuration to determine which need to be compiled and which do not need to be compiled

# Make dep

3. Delete all files left in the previous step to avoid errors. (Skip this step if the new download kernel has not been compiled)

# Make clean

4. Compile the kernel

# Make bzImage

After the above command is compiled successfully, the/usr/src/kernels/linux-2.6.26.2/arch/x86/boot/

Directory to generate a new kernel image bzImage

5. Compile and load the kernel module

# Make modules

6. Copy the generated modules to the desired directory.

# Make modules_install

7. Generate the dependency between modules. After the new kernel is started, the module can be determined when the modprobe command is used to load the module.

# Depmod

-A note Step 5-7 is necessary only when Enable loadable module support (CONFIG_MODULES) is selected during Kernel configuration.

After the above steps, a new kernel and module are generated. In order to be able to use the new kernel, the following work should be done.

 
 
  1. #cp /usr/src/kernels/linux-2.6.26.2/System.map /boot    
  2. #cp /usr/src/kernels/linux-2.6.26.2/arch/x86/boot/bzImage /boot     
  3. #cd /boot   #mv bzImage vmlinuz-2.6.26  

Note that the previous two commands did not overwrite the original kernel image and kernel symbol stealth table like many other posts on the Internet. Put the new one directly under/boot, so that the new kernel can be started when the new kernel cannot be started. We hope this article will help you compile the kernel module.

  1. How to install Linux NICs
  2. Install and configure the Linux Ethernet Card
  3. Fully understand the operating principles of Linux NICs
  4. Do you know about Linux boot?
  5. Teach you how to send emails and fax in Linux

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.