Linux Kernel Driver (I): 2. Linux Kernel configuration and compilation

Source: Internet
Author: User

I. Linux configuration and compilation

Linux has the following advantages:

1. Clear temporary files, intermediate files, and configuration files

(1) make clean: delete most of the generated files, but keep the configuration file

(2) Make mrproper: delete all generated files and configuration files

(3) make distclean: Delete the patch and backup files of the editor based on make mrproper.

2. Determine the hardware and software configurations of the target system, such as the CPU type, network card model, and required network protocols.

3. Use one of the following commands to configure the kernel:

(1) make config: Interactive configuration based on text mode

(2) Make menuconfig: text-based menu configuration (recommended)

(3) make oldconfig: use the existing configuration file (. config ),

(4) Make xconfig: Graphical Configuration

After the configuration command is run, A. config file is generated under the root directory of the kernel source code.

Note: in actual application, we do not need to read all the configuration options one by one, but re-configure an existing configuration.

4. Compile the kernel:

I, (1) make zimage (2) Make bzimage

Difference: On the X86 platform, zimage can only be used for kernels smaller than kb. In addition, if you want to obtain detailed compilation information, you can add parameters.

Make zimage v = 1; Make bzimage v = 1;

II. The compiled kernel is located in the arch/<CPU>/boot directory.

5. Compile the kernel module: Make modules

6. Install the kernel module: Make modules_install.Source codeDirectory copy to/lib/modules

7. Create init ramdisk:

Mkinitrd initrd-$ vsersion $ version. Note that this command has two parameters. The first parameter is usually named as initrd-$ version and 2nd, it must be the actual kernel version. For example: Make
Initrd-2.6.29 2.6.29.

8. kernel installation (eg: x86 Platform)

(1) cp arch/x86/boot/bzimage/boot/vmlinuz-$ version // copy the bzimage file to the boot directory. The vmlinuz-$ version name can be used as needed, but we generally use this form

(2) CP $ initrd/boot // copy the rimdisk to the/boot directory.

(3) Modify/etc/grub. conf or/etc/Lilo. conf.

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.