Detailed analysis of memory disk Initialization Technology in Linux

Source: Internet
Author: User
Article Title: detailed analysis of memory disk Initialization Technology in Linux. 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.

Linux memory initialization Technology (initrd) is used to support two-phase system boot process. It is a temporary root file system mounted during system startup: here, the root file system refers to the root file system ). Initrd contains many executable programs and drivers, and allows the root file system of the temporary memory disk to be detached. After the memory is released, the real root file system is mounted. Initrd is the final root file system in many embedded linux file systems. This article mainly describes the initrd Technology of linux2.6 kernel, including the creation and use of the kernel.

1 What is memory disk initialization?

Initrd has a higher Mount priority than the real root file system. It is attached to the kernel and is loaded as part of the kernel startup process ). Then, as the first part of the two-phase boot process, the kernel mount (mount) initrd is used to obtain and load a truly valid file system.

For this purpose, initrd contains the minimum directory and programs, such as insmod, to install the kernel module into the kernel.

For desktop or Server linux, initrd is a temporary file system with a short life cycle. It serves only as a bridge to reach the real root file system. But for an embedded system without storage devices, it is a permanent root file system. This article involves both aspects.

2. In-depth analysis of initrdL

Initrd contains necessary programs and system files for supporting the second-stage process of system startup. The method for creating the initialization Memory changes with the system version you are using. After coreora Core3, initrd is established by the loop device. What is a send-back device? It is a device driver that allows you to mount a file as a block device and describe its file system. Maybe the loop device does not exist in your kernel, but you can open it through the Kernel configuration tool (make menuconfig. Path: Device Drivers-Block Devices-LoopBack Device support. The following is the check command:

# Mkdir temp; cd temp

# Cp/boot/initrd.img.gz.

# Gunzip initrd.img.gz

# Mount-t ext-o loop initrd. img/mnt/initrd

# Ls-la/mnt/initrd

#

Now, you can view the content of initrd by viewing the/mnt/initrd subdirectory. In other words, your initrdimage file does not use .gz as the suffix, but you can also enable gunzip to open it by adding the suffix.

Starting from Fedora Core3, the default initrd image is a compressed gpio archive file. In addition to mounting files, you can also use cpio to archive files to mount them into a compressed image using the return device. You can run the following command to check the content of the cpio archive file:

# Mkdir temp; cd temp

# Cp/boot/initrd-2.6.14.2.img initrd-2.6.14.2.img.gz

# Gunzip initrd-2.6.14.2.img.gz

# Cpio-I -- make-directories initrd-2.6.14.2.img

The result is a small root file system, as shown below:

# Ls-la

#

Drwxr-xr-x 10 root 4096 May 7.

Drwxr-x --- 15 root 4096 May 7 ..

Drwxr-xr-x 2 root 4096 May 7 bin

Drwxr-xr-x 2 root 4096 May 7 dev

Drwxr-xr-x 4 root 4096 May 7 etc

-Rwxr-xr-x 1 root 812 May 7 init

-Rw-r -- 1 root 1723392 May 7 initrd-2.6.14.2.img

Drwxr-xr-x 2 root 4096 May 7 lib

Drwxr-xr-x 2 root 4096 May 7 loopfs

Drwxr-xr-x 2 root 4096 May 7 proc

Lrwxrwxrwx 1 root 3 May 7 sbin-> bin

Drwxr-xr-x 2 root 4096 May 7 sys

Drwxr-xr-x 2 root 4096 May 7 sysroot

#

Some small, but it is necessary for a program combination in. the/bin directory contains nash (not a shell, but a script interpretation tool), insmod for loading kernel modules, and lvm.

The initialization file in the root directory is relatively interesting in the directory shown above. These files are generated when the initrd image is decompressed to RAM, just as in the traditional linux Startup Process. We will continue to discuss this issue later.

[1] [2] [3] [4] Next page

Related Article

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.