Several important RedHatLinux kernel files

Source: Internet
Author: User
Article Title: several important RedHatLinux kernel files. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
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. Run the following command in/boot: ls? L. 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.
  
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 are embedded with gzip decompression code at the beginning of the two files. So you cannot use gunzip or gzip? The dc unpackage vmlinuz. 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. zImage. vmlinux cannot be used as uncompressed kernels, 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. 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.
  
The initrd image file is created using mkinitrd. The mkinitrd utility can create an initrd image file. This command is proprietary to RedHat. Other Linux distributions may have corresponding commands. This is a very convenient utility. For details, see help: man mkinitrd
  
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, during kernel compilation. map is created in/usr/src/linux-2.4/System. map. like below: nm/boot/vmlinux-2.4.7-10> System. map the following lines from/usr/src/linux-2.4/Makefile: nm vmlinux | grep-v '(compiled) | (. O $) | ([aUw]) | (...... Ng $) | (LASH [RL] DI) '| sort> System. map and then copy to/boot: cp/usr/src/linux/System. map/boot/System. map-2.4.7-10
  
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. 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, but other programs such as klogd, lsof and ps need a correct System. map. if you are using an error or do not have System. the output of map and klogd is unreliable, which makes it difficult to troubleshoot program faults. 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 execute name-Address Resolution, klogd needs to use System. map. System. map to find it in the software that uses it. Run: man klogd. map is used as the location of a variable to klogd, so it will search for System in three places in the following order. map:/boot/System. map/System. map/usr/src/linux/System. map System. map also has version information. klogd can intelligently find the correct map file.

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.