Tuesday, July 12, 2011

Detailed three core documents

In the network, the server uses a lot of Linux systems. To further improve the performance of the server, may need specific hardware and needs to recompile the Linux kernel. Compile the Linux kernel, the steps required under the regulations, the kernel process involves several important documents. For example, RedHat Linux , the / boot directory there are some Linux kernel-related files into the / bootexecute: ls-L . Compiled RedHat Linux kernel people in one of the System.map , vmlinuz , initrd-2.4.7-10.img impression may be more profound, because the kernel involved in the process of these documents to establish such an operation. So how these documents are produced? What effect? This paper describes do

A, vmlinuz
vmlinuz is the bootable compressed kernel. "Vm" on behalf of "Virtual Memory . " Linux supports virtual memory, unlike the old operating system, such as: DOS has 640KB memory limit. Linux can use hard disk space as virtual memory, hence the name "vm" . vmlinuz is the executable Linux kernel in / boot / vmlinuz , which is generally a soft link
vmlinuz establishment of two ways:
The first method: the kernel is compiled by "make zImage" to create, and then: "cp / usr/src/linux-2.4/arch/i386/linux/boot/zImage / boot / vmlinuz " generation. zImage for the case of a small kernel, it exists for backward compatibility
The second method: kernel compile-time with the command " make bzImage " to create, and then: cp / usr/src/linux-2.4/arch/i386/linux/boot/bzImage / boot / vmlinuz " generation. bzImage is the compressed kernel image, note, bzImage not use bzip2 compression, bzImage in bz misleading, BZ said"Big zImage" . bzImage in b is a "big" means
zImage ( vmlinuz ) and bzImage ( vmlinuz ) is to use gzip compression. They are not only a compressed file, and in the beginning of the two files embedded gzip decompression code. So you can not use gunzip or gzip-dc unpack vmlinuz
, core file contains a miniature gzip to decompress the kernel and boot it. The difference is that the old zImage kernel to extract low-memory (first 640K ), bzImage decompression kernel into high memory (1MAbove). If the kernel is small, you can use zImage or bzImage , one of two ways to boot the system is running is the same. Large kernel using bzImage , not use zImage
vmlinux is the uncompressed kernel, vmlinuz is vmlinux compressed files.
Two, initrd-xxximg
initrd is the initial ramdisk " shorthand. initrd is generally used for temporary guide to the actual hardware kernel, vmlinuz to take over and continue to lead the state. initrd-2.4.7-10.img is mainly used to load the ext3 file system and other scsi device driver. For example, using a scsi hard drive, while the kernel vmlinuz and do not have this in the scsi hardware drivers, then load the scsi module, the kernel can not load the root file system, but the scsi module is stored in the root file system / lib / modulesunder the . To solve this problem, can lead one to read the actual kernel initrd and kernel with initrd fixscsi booting problems. initrd-2.4.7-10.img is gzip compressed file
linuxrc script initrd to achieve a number of modules to load and install the file system. initrd image file is to use mkinitrd to create. mkinitrd utility to create initrd image file. This command is RedHat -specific.Other Linux distributions may have a corresponding command. This is a very handy utility. See the specific circumstances of help: man mkinitrd

Three, System.map
System.map is a specific kernel of the kernel symbol table. It is your currently running kernel System.maplinks.
How the kernel symbol table is created it ? System.map is "nm vmlinux" generated and the symbol was not related to filter out. For the examples in this article, compiling the kernel, System.map is created in / usr/src/linux-2.4/System.map . Like this: 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.mapand then copy it to / boot : cp / usr / src / Linux / System.map / boot / System . map-2.4.7-10
During programming, it will name a few variables or function names like symbols. Linux kernel is a very complex block of code, there are many global symbols. Linux kernel does not use a symbolic name, but by the address of a variable or function to identify the variable or function names. Such as not using size_t BytesRead such symbols, but as c0343f20 that refer to this variable.
For the use of computers for people who prefer to use those as size_t BytesRead such a name, not like asc0343f20 such names. Core is mainly used c to write, so the compiler / encoder connector allows us to use symbolic names, use the address when the kernel is running.
However, in some cases, we need to know the address of the symbol, or need to know the address of the corresponding symbol. This is done by the symbol table, symbol table of all symbols along with their addresses. Variable name checkCPUtype in the kernel address c01000a5
Linux uses the symbol table to 2 files:    / proc / ksyms   System.map
1 ) / proc / ksyms is a "proc file" , created when the kernel boots. In fact, it is not really a file, it is only the kernel of data that gave people the illusion of a disk file, the file size that it is from 0 can be seen. However, System.map is present in the file system on your actual file. When you compile a new kernel, the address of each symbolic name to change, your old System.map has wrong symbol information.Generated when compiling a kernel for each new System.map , you should use the new System.map to replace the old System.map . Although the kernel itself does not really use System.map , but other programs such as: klogd , lsof and ps and other software requires a correct System.map . If you use the wrong or no System.map , klogd output will be unreliable, which would exclude the difficult process failure. No System.map , you may face some troubling message.
2 ) In addition, a few drivers need System.map to resolve symbols, not specific to your currently running kernel to create the System.map they will not work. Linux kernel log daemon: klogd to perform name ---- address resolution, klogd to use System.map . System.map should be placed to use its software can find its place. Executive: man klogd known, if not the System.map position as a variable to klogd , it will in the following order, in three places to find System.map : / boot / System.map , / System.map ,/ usr / src / Linux / System.map ; System.map also has version information, klogd can be smart to find the right image ( map ) file