Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of compiling the kernel by Linux

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "the process of compiling the kernel with Linux". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the process of compiling the kernel with Linux".

Linux compiles the kernel

Preparatory work

Usually the first command to run is:

# cd / usr/src/linux;make mrproper

This command ensures that there are no incorrect .o files and file interdependencies in the source code directory

Configuration

The next kernel configuration process of  is cumbersome, but whether the configuration is appropriate or not is directly related to the future operation of Linux, so it is necessary to know the settings of some major and frequently used options.

The  configuration kernel can use one of the following commands according to your needs and preferences:

# make config (the most traditional text-based configuration interface, not recommended)

# make menuconfig (based on the text menu configuration interface, recommended under character terminals)

# make xconfig (based on the configuration interface of graphical window mode, recommended under Xwindow)

# make oldconfig (if you only want to modify a few small areas based on the original kernel configuration, it will save a lot of trouble)

Of the three  commands, make xconfig has the most friendly interface. If you can use Xwindow, it is recommended that you use this command.

After the complicated configuration work is completed, you can wait patiently for a cup of tea by yourself. There are several commands related to compilation:

# make dep

# make clean

# make zImage

# make bzImage

# make modules

# make modules_install

# depmod-a

 's first command, make dep, actually reads the configuration file generated by the configuration process to create a dependency tree corresponding to the configuration, thus determining which needs to be compiled and which does not

The second command make clean finishes deleting the files left by the previous steps to avoid some errors

The third command, make zImage, and the fourth command, make bzImage, achieve complete kernel compilation. Both of the generated kernels are compressed using gzip, and only one is enough.

The difference between them is that you can use make bzImage to generate a larger kernel. For example, if you use the make zImage command when compiling the 2.4.0 kernel, there will be an error prompt for system too big.

We recommend that you use the make bzImage command.

The last three commands of  are necessary only if you choose "Yes" when answering Enable loadable module support (CONFIG_MODULES) during your configuration.

Make modules and make modules_install generate the corresponding modules and copy the modules to the desired directory, respectively.

 strictly speaking, the seventh command has nothing to do with the compilation process, it is the dependency between the generation modules, so that after you start the new kernel, you can correctly locate the module when you use the modprobe command to load the module.

Update

After the above steps,  finally got a new version of the kernel. In order to be able to use the new version of the kernel, we also need to make some changes:

# cp / usr/src/linux/System.map / boot/System.map-2.4.0test8

# cp / usr/src/linux/arch/i386/bzImage / boot/vmlinuz-2.4.0test8

 these two files are newly generated when we compiled just now. The following modifies the two links System.map and vmlinuz under / boot to point to the file of the new kernel:

# cd / boot;rm-f System.map vmlinuz

# ln-s vmlinuz-2.4.0test8 vmlinuz

# ln-s System.map-2.4.0test8 System.map

# shutdown-r now

Start normally. Your machine is using your new kernel now.

Here are the compilation methods recommended by RH. Pay attention to edit Makefile

As the old saying goes, RedHat recommends the method of compiling the kernel.

This article is partly taken from the RH300 (RHCE Rapid Track Course) textbook.

This article assumes that you are using Redhat 7.2 and use grub to manage startup. Prepare to compile 7.2 built-in kernel

Cd / usr/src/linux-2.4

Make mrproper

Edit Makefile file

Change EXTRAVERSION= into words with your own characteristics, such as:

EXTRAVERSION=-10me

Make menuconfig or make xconfig

Make dep

Make bzImage

Make modules

Make modules_install

Cp System.map / boot/System.map-2.4.7-10me

Cp arch/i386/boot/bzImage / boot/vmlinuz-2.4.7-10me

New-kernel-pkg-- install-- mkinitrd-- depmod 2.4.7-10me

At this point, I believe you have a deeper understanding of "the process of compiling the kernel by Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report