Several important RedHat Linux kernel files
Author: IHH posting time: 2005.10.08
From: http://www.ccidnet.com
In the network, many servers use Linux systems. To further improve the server performance, you may need to recompile the Linux kernel based on specific hardware and requirements. To compile the Linux kernel, you must follow the required steps. Several important files are involved in compiling the kernel. For example, for Redhat Linux, there are some Linux kernel-related files in the/boot directory and the files are executed in/boot.
People who have compiled the RedHat Linux kernel may be impressed with system. Map, vmlinuz, and initrd-2.4.7-10.img, because operations such as file creation are involved during kernel compilation. How are these files generated? What role does it play? This article introduces this topic.
I. vmlinuz
Vmlinuz is a bootable and compressed kernel. "VM" represents "Virtual Memory ". Linux supports Virtual Memory. Unlike earlier operating systems such as DOS, there is a limit of KB memory. Linux can use hard disk space as virtual memory, so it is named "VM ". Vmlinuz is an executable Linux kernel located in/boot/vmlinuz, which is generally a soft link than a soft link in the vmlinuz-2.4.7-10.
There are two ways to establish vmlinuz. One is to compile the kernel through "make zimage" to create, and then through: "CP/usr/src/linux-2.4/ARCH/i386/Linux/boot/zimage/boot/vmlinuz" generated. Zimage is suitable for small kernels. It exists for backward compatibility.
The second is when the kernel is compiled by the command make bzimage to create, and then through: "CP/usr/src/linux-2.4/ARCH/i386/Linux/boot/bzimage/boot/vmlinuz" generated. Bzimage is a compressed kernel image. It should be noted that bzimage is not compressed with Bzip2, and BZ in bzimage is easy to misunderstand. BZ indicates "Big zimage ". B In bzimage means "big. Both zimage (vmlinuz) and bzimage (vmlinuz) are compressed using gzip. They are not only a compressed file, but also embedded with gzip at the beginning of the two filesCode. Therefore, you cannot use gunzip or gzip-DC to unpackage vmlinuz.
The kernel file contains a micro gzip used to extract the kernel and boot it. The difference between the two is that the old zimage decompress the kernel to the low-end memory (the first 640 K), and The bzimage decompress the kernel to the high-end memory (more than 1 MB ). If the kernel is small, zimage or bzimage can be used. The two methods guide the same system runtime. Bzimage is used for large kernels, and zimage cannot be used. Vmlinux is an uncompressed kernel and vmlinuz is a compressed file of vmlinux.
2. 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. The initrd-2.4.7-10.img in the figure is mainly used to load the driver of file systems and SCSI devices such as ext3.
For example, if a SCSI hard disk is used, and the kernel vmlinuz does not have the SCSI hardware driver, the kernel cannot load the root file system before the SCSI module is loaded, however, the SCSI module is stored in/lib/modules of the root file system. To solve this problem, we can guide an initrd kernel that can read the actual kernel and use initrd to correct the SCSI Boot problem. Initrd-2.4.7-10.img is compressed with gzip files, initrd to load some modules and install file systems and other functions.
The initrd image file is created using mkinitrd. Mkinitrd UtilityProgramAllows you to create initrd image files. This command is proprietary to RedHat. Other Linux distributions may have corresponding commands. This is a very convenient utility. For more information, see help: run the following command under man mkinitrd to create an initrd image file.
3. system. Map
System. Map is a kernel symbol table of a specific kernel. It is the link to the system. Map of your currently running kernel.
How is the kernel symbol table created? System. MAP is generated by "nm vmlinux" and irrelevant symbols are filtered out.
For the example in this article, when compiling the kernel, system. MAP is created at/usr/src/linux-2.4/system. Map. As shown below:
Nm/boot/vmlinux-2.4.7-10> system. Map
The following lines are from/usr/src/linux-2.4/makefile:
NM vmlinux | grep-V '/(Compiled/)/| /(/. o $/)/|/([auw]/)/| /(/. /. ng $/)/|/(lash [RL] di/) '| sort> system. map
Then copy to/boot:
CP/usr/src/Linux/system. MAP/boot/system. Map-2.4.7-10
Is part of the system. map file:
Some symbols such as variable names or function names are named during program design. Linux Kernel is a complex code block with many global symbols.
The Linux kernel uses a variable or function name instead of a symbolic name. For example, instead of using a symbol like size_t bytesread, the variable is referenced like c0343f20.
For people who use computers, they prefer names like size_t bytesread rather than c0343f20. The kernel is mainly written in C, so the compiler/connector allows us to use a symbolic name for encoding and an address for Kernel running.
However, in some cases, we need to know the address of the symbol or the symbol corresponding to the address. This is done by the symbol table, which is a list of all symbols along with their addresses. It is a kernel symbol table. It can be seen that the variable name checkcputype is at the kernel address c01000a5.
The Linux symbol table uses two files:
/Proc/ksyms
System. Map
/Proc/ksyms is a "proc file" created during kernel boot. In fact, it is not really a file. It is just a representation of kernel data, but it gives people the illusion of a disk file, which can be seen from its file size being 0. However, system. map exists in the actual file system.
When you compile a new kernel, the address of each symbol name changes. Your old system. MAP has incorrect symbol information. Each time the kernel is compiled, a new system. MAP is generated. You should replace the old system. map with the new system. Map.
Although the kernel itself does not actually use system. Map, other programs such as klogd, lsof, and PS need a correct system. Map. If you use incorrect or do not have system. MAP, the output of klogd will be unreliable, which will cause difficulties in troubleshooting the program. Without system. map, you may face annoying prompts.
In addition, a few drivers need system. Map to parse the symbols. If system. map is not created for the specific kernel you are running, they cannot work normally.
For Linux kernel log daemon klogd to perform name-Address Resolution, klogd needs to use system. Map. System. map should be placed where the software that uses it can find it. Run: Man klogd. If system. map is not given to klogd as a variable, it searches for system. map in the following order:
/Boot/system. Map
/System. Map
/Usr/src/Linux/system. Map
System. MAP also has version information. klogd can intelligently find the correct map file.