Introduction to several important Linux system kernel files

  

In the network, many servers use Linux. In order to further improve the performance of the server, it may be necessary to recompile the Linux kernel according to specific hardware and requirements. To compile the Linux kernel, you need to follow the prescribed steps. Several important files are involved in compiling the kernel. For example, for RedHat Linux, there are some files related to the Linux kernel in the /boot directory, and enter /boot to execute: ls –l. Those who have compiled the RedHat Linux kernel may have a deep impression on System.map, vmlinuz, initrd-2.4.7-10.img, because the process of compiling the kernel involves the establishment of these files. So how did these files come about? What is the role? This article will introduce some of this.

1. vmlinuz

vmlinuz is a bootable, compressed kernel. “vm” stands for "Virtual Memory". Linux supports virtual memory, unlike older operating systems such as DOS that have a 640KB memory limit. Linux can use hard disk space as virtual memory, hence the name "vm". Vmlinuz is an executable Linux kernel located at /boot/vmlinuz, which is typically a soft link.

There are two ways to build vmlinuz. First, when compiling the kernel, create it by “make zImage”, then pass:

“cp /usr/src/linux-2.4/arch/i386/linux/boot/zImage /boot/vmlinuz” zImage works in the case of small kernels and exists for backward compatibility. The second is that the kernel is compiled with the command make bzImage, and then generated by: < cp /usr/src/linux-2.4/arch/i386/linux/boot/bzImage /boot/vmlinuz” bzImage is a compressed kernel image. Note that bzImage is not compressed with bzip2. bz in bzImage is easy to misunderstand, bz means "big zImage". b in bzImage is "big" meaning.

zImage(vmlinuz) and bzImage(vmlinuz) are both compressed with gzip. Not only are they a compressed file, but gzip decompressed code is embedded in the beginning of the two files. So you can't unpack vmlinuz with gunzip or gzip –dc.

The kernel file contains a tiny gzip for decompressing the kernel and booting it. The difference between the two is that the old zImage decompresses the kernel to low-end memory (the first 640K), and bzImage decompresses the kernel to high-end memory (1M or more). If the kernel is small, you can use one of zImage or bzImage. The system running in the two ways is the same. Large kernels use bzImage and cannot use zImage.

vmlinux is an uncompressed kernel, vmlinuz is a compressed file of vmlinux.

Second, initrd-x.x.x.img

initrd is short for “initial ramdisk”. Initrd is generally used to temporarily boot the hardware to the state where the actual kernel vmlinuz can take over and continue to boot. For example, if you use a scsi hard disk, and the kernel vmlinuz does not have this scsi hardware driver, the kernel cannot load the root file system before loading the scsi module, but the scsi module is stored under the /lib/modules of the root file system. To solve this problem, you can boot an initrd kernel that reads the actual kernel and use initrd to fix the scsi boot problem. Initrd-2.4.7-10.img is a file compressed with gzip. Let's take a look at the contents of this file.

The initrd implementation loads some modules and installs filesystems, etc.

The initrd image file is created using mkinitrd. The mkinitrd utility is able to create initrd image files. This command is proprietary to RedHat. Other Linux distributions may have corresponding commands. This is a handy utility. For details, please refer to the help: man mkinitrd

The following command creates an initrd image file:

3. System.map System.map is a kernel symbol table for a specific kernel. It is a link to the System.map of the kernel you are currently running.

How is the kernel symbol table created? System.map is generated by “nm vmlinux” and the unrelated symbols are filtered out. For the examples in this article, System.map is created in /usr/src/linux-2.4/System.map when compiling the kernel. Like this:

nm /boot/vmlinux-2.4.7-10 > System.map

The following lines are from /usr/src/linux-2.4/Makefile:

nm vmlinux

Copyright © Windows knowledge All Rights Reserved