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

What are the important kernel files commonly used in RedHat systems

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

Share

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

This article focuses on "which important kernel files are commonly used in the RedHat system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what important kernel files are commonly used in the RedHat system.

1. Vmlinuz

Vmlinuz is a bootable, compressed kernel. "vm" stands for "Virtual Memory". Linux supports virtual memory, unlike older operating systems such as DOS, which have 640KB memory limitations. Linux can use hard disk space as virtual memory, hence the name "vm". Vmlinuz is the executable Linux kernel, which is located in / boot/vmlinuz. It is usually a soft link, such as the soft link of vmlinuz-2.4.7-10 in the figure.

There are two ways to establish vmlinuz. First, when compiling the kernel, it is created by "make zImage" and then generated by: "cp / usr/src/linux-2.4/arch/i386/linux/boot/zImage/boot/vmlinuz". ZImage is suitable for small kernels, and it exists for backward compatibility.

Second, the kernel is created by the command make bzImage when compiling, and then generated by: "cp/usr/src/linux-2.4/arch/i386/linux/boot/bzImage / boot/vmlinuz". BzImage is a compressed kernel image, it should be noted that bzImage is not compressed with bzip2, bz in bzImage is easily misleading, and bz stands for "big zImage". The b in bzImage means "big". Both zImage (vmlinuz) and bzImage (vmlinuz) are compressed with gzip. They are not only a compressed file, but also have gzip unzipped code embedded in the beginning of both files. So you can't unpack vmlinuz with gunzip or gzip-dc.

The kernel file contains a miniature gzip to extract the kernel and boot 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 (more than 1m). If the kernel is small, you can use either zImage or bzImage, both of which boot the system at the same runtime. Large kernels use bzImage, not zImage. Vmlinux is the uncompressed kernel and vmlinuz is the compressed file of vmlinux.

II. Initrd-x.x.x.img

Initrd is an abbreviation for "initial ramdisk". Initrd is generally used to temporarily boot the hardware to a 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 drivers for file systems such as ext3 and scsi devices.

For example, if you are using a scsi hard disk and the kernel vmlinuz does not have a driver for this scsi hardware, the kernel cannot load the root file system until the scsi module is mounted, but the scsi module is stored under / lib/modules of the root file system. To solve this problem, you can boot an initrd kernel that can read the actual kernel and fix the scsi boot problem with initrd. Initrd-2.4.7-10.img is a file compressed by gzip, and initrd implements the functions of loading some modules and installing the file system.

The initrd image file is created using mkinitrd. The mkinitrd utility can create initrd image files. This command is proprietary to RedHat. Other Linux distributions may have commands accordingly. This is a very convenient utility. For more information, see the help: the command below man mkinitrd creates an initrd image file.

III. 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 unrelated symbols are filtered out.

For the example in this article, when the kernel is compiled, the System.map is created at / usr/src/linux-2.4/System.map. Like this:

The code is as follows:

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

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

The code is as follows:

Nm vmlinux | grep-v'\ (compiled\)\ |\ (\ .o $$\)\ |\ ([aUw]\)\ |\ (\. Ng$$\)\ |\ (Lash [RL] DI\)'| sort > System.map

Then copy to / boot:

The code is as follows:

Cp / usr/src/linux/System.map / boot/System.map-2.4.7-10

The following figure is part of the System.map file:

When programming, symbols such as variable names or function names are named. The Linux kernel is a complex block of code with many global symbols.

Instead of using symbolic names, the Linux kernel identifies variable or function names by the address of the variable or function. For example, instead of using symbols like size_t BytesRead, you refer to this variable like c0343f20.

For people who use computers, they prefer names like size_t BytesRead to names like c0343f20. The kernel is mainly written in c, so the compiler / connector allows us to use symbolic names when coding and addresses when the kernel is 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 a symbol table, which is a list of all symbols along with their addresses. The above image is a kernel symbol table, which shows that the variable name checkCPUtype is at the kernel address c01000a5.

The Linux symbol table uses 2 files:

The code is as follows:

/ proc/ksyms

System.map

/ proc/ksyms is a "proc file" that is created during kernel boot. In fact, it's not really a file, it's just a representation of kernel data, but it gives people the illusion of a disk file, as can be seen from its file size of 0. However, System.map is the actual file that exists on your file system.

When you compile a new kernel, the address of each symbol name changes, and your old System.map has the wrong symbolic information. Every time the kernel compiles a new System.map, you should replace the old System.map with the new System.map.

Although the kernel itself doesn't really use System.map, other programs such as klogd,lsof and ps need a correct System.map. If you use the wrong output or without System.map,klogd, it will be unreliable, which will make it difficult to troubleshoot the program. Without System.map, you may be faced with some annoying prompts.

A few other drivers need System.map to parse symbols, and they won't work without a System.map created for the specific kernel you're running.

Linux's kernel log daemon, klogd, requires System.map for klogd to perform name-to-address resolution. System.map should be placed where the software that uses it can find it. Execution: man klogd knows that if System.map is not given to klogd as a variable, it will look for System.map in three places in the following order:

The code is as follows:

/ boot/System.map

/ System.map

/ usr/src/linux/System.map

System.map also has version information, and klogd can intelligently find the correct image (map) file.

At this point, I believe you have a deeper understanding of "which important kernel files are commonly used in the RedHat system". 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