Vmlinuz, initrd, system. Map File

Source: Internet
Author: User

 I. vmlinuz


Vmlinuz is a bootable and compressed kernel. "VM" represents "Virtual Memory ". Linux supports Virtual


Internal
Memory, unlike the old operating system, such as DOS, which has a limit of KB memory. Linux can use hard disk space as virtual memory, so it is named "VM ". Vmlinuz is executable.
Linux Kernel, which is located in/boot/vmlinuz, it is generally a soft link, than the soft link in the vmlinuz-2.4.7-10.

There are two ways to establish vmlinuz.


First, create the kernel through "make zimage" and run the following command: "CP
/Usr/src/linux-2.4/ARCH/i386/Linux/boot/zimage/boot/vmlinuz "is generated. Zimage applies
In the case of a small kernel, it exists for backward compatibility.

Second, run the make command during kernel compilation.
Bzimage created and then passed: "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, and BZ in bzimage is prone
Misunderstanding: 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 at the beginning of the two files
Decompress the gzip code. Therefore, you cannot use gunzip or gzip-DC to unpackage vmlinuz.

The kernel file contains a tiny GZIP file for decoding.
Compress 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 ). For example
If the kernel is relatively 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 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, but the SCSI
The 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 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. The mkinitrd utility can create an initrd image file. This command is proprietary to RedHat. Others
The Linux release 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 are using an error
Without system. MAP, the output of klogd will be unreliable, which will lead to difficulties in troubleshooting the program. Without system. map, you may face some annoying issues.
Information.

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 in the software that uses it
Find its location. Run: Man
Klogd indicates that 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.

 

From: http://blog.chinaunix.net/u3/106136/showart.php? Id = 2095656

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.