[Rootfs] Initramdisk & InitRamfs Introduction and use

Source: Internet
Author: User
First, RootfsRootfs,root FileSystem, refers to the root file system, the corresponding/directory node. Rootfs is also divided into virtual rootfs and real rootfs.
The virtual Rootfs is created and loaded by the kernel itself, only in memory (subsequent INITRAMFS are also implemented on this basis), and its file system is TMPFS type or RAMFS type.
The real rootfs is that the root filesystem exists on the storage device, and the kernel mounts the storage device on the virtual rootfs during boot, and then switches the/directory node to the storage device. This allows the file system on the storage device to be used as the root file system (subsequent Initramdisk is implemented on this basis), with a richer file system type, which can be ext2, yaffs, YAFFS2, and so on, and is determined by the type of the specific storage device.

Second, Initramdisk & InitRamfsBoth Initramdisk and INITRAMFS technologies use the area of RAM as the root file system. 1, the difference is as follows
(1) The realization of the difference in principle Initramdisk, initialize the memory disk INITRD (INITial RAM disk) technology, using RAMDisk technology, the system part of the memory area is implemented as/dev/ram,/dev/ram as a storage set Switch the root directory to the/dev/ram mount for the purpose of/dev/ram as the root file system. It is really rootfs from the principle.
InitRamfs, a Cpio compressed description packet containing the file, directory, node of the root file system is released directly into the memory area of the virtual Rootfs, followed by Rootfs as the system's root file system, without the need for block device participation.
(2) Differences on file systems
Initramdisk, using the ext2 format file system.
InitRamfs, using the kernel kernel directly supports the ROOTFS format of the file system.
(3) Differences in data flow
Initramdisk, need to go through ext2 file system and/dev/ram device
InitRamfs, directly through the Rootfs file system

(3) initialization process init Initramdisk, using/LINUXRC under the root filesystem as the init process InitRamfs, using/init under the root file system as the INIT process
(4) Differences in kernel support versions
Initramdisk, supported by the kernel 2.4 release
INITRAMFS, supported by the kernel 2.6 release
(5) The difference between the image and the way of production will be explained later

2. Advantages and Disadvantages
(1) Advantages of INITRAMFS
Initramfs saves you from creating/dev/ram, hooking up the file system, and switching the root directory, and the startup process is much simpler and faster.
At the same time, INITRAMFS is simpler and faster than Initramdisk, and kernel's internal processing of INITRAMFS is simpler. (2) Disadvantages of Initramfs
Initramfs uses the Cpio package, contains the file, directory, node Description Language pack, in order to describe a file, directory, node, to add a lot of additional descriptive text overhead. This makes the Cpio package much larger than the corresponding image file.

iii. Description of nouns and typesBecause there are many kinds of nouns on the internet for INITRD, because here do explain and unify the explanation.
The Initramdisk and InitRamfs have been mentioned earlier, while InitRamfs is divided into independent InitRamfs and integrated InitRamfs.
1, Initramdisk
The initrd of the old block device, corresponding to the image of the Init RAMDisk, the format ext2.
Online nouns: image-initrd, may also be directly used INITRD to express Initramdisk, the specific need to judge according to the article itself.

2, independent type Initramfs
Refers to the Initramfs compressed package and kernel image independent, corresponding to the INITRAMFS compression package, is a cpio format compression of a separate file.
Online noun: cpio-initrd (essentially belongs to Initramfs type)

3, integrated type Initramfs
Refers to the integration of the Initramfs Cpio compression package into kernel image, the Cpio compressed file is linked into a special data segment in the kernel. INIT.RAMFS, where global variables __initramfs_start and __ The initramfs_end points to the starting and ending addresses of the data segment, respectively. When the kernel starts, it extracts the data from the. Init.ramfs segment and uses it as a temporary root file system.
Online noun: Initramfs (it really belongs to the Initramfs type, but it is one of the types)

Four,Production of Initramdisk & Initramfs 1, Initramdisk
(1) The General command is as follows:
Genext2fs-b 4096-d rootfs RAMDisk gzip-9-F ramdisk mkimage-n "My rootfs"-A arm-o linux-t ramdisk-c gzip-d Ramdis            k.gz ramdisk.img <1> genext2fs is used to generate a ext2 format for the directory RAMDisk. -B refers to the size of the RAMDisk made of 4096K bytes. -D refers to the root file system directory to be made into RAMDisk.
RAMDisk refers to the name of the RAMDisk to be generated
<2> gzip Compress the RAMDisk in the best way to ramdisk.gz
<3> The third step is used by Uboot, The Mkimage command converts the compressed RAMDisk root file system binaries ramdisk.gz to u-boot recognizable binary ramdisk.img and specifies RAMDISK.IMG's name "My Rootfs", The processor architecture is arm, the operating system type is Linux, the program type is RAMDisk, the program is compressed by gzip, and you do not need to specify RAMDisk link start address and ingress address. use fit mode to skip this step.
(2) In X Project Project The method is as follows (need to switch to tiny210 Branch) in Config.mk to modify the following:
# # # # Defining ROOTFS image type that want is generate. # # Rootfs_image_type=ramdisk #ROOTFS_IMAGE_TYPE =initramfs
After the ROOTFS has been generated (BusyBox installation is complete), execute
Make Rootfs the final generated ramdisk.gz, ramdisk.img is the image that Initramdisk needs to use. Ramdisk.gz is used in fit mode and ramdisk.img is used under traditional uimage.
The corresponding build script is in build/script/mkrootfs.sh
# # Generate RAMDisk image for Rootfs. If ["$ROOTFS _image_type" = "$TYPE _initramdisk"]; Then         genext2fs-b 4096-d ${rootfs_dir} ${rootfs_out_dir}/${type_initramdisk}     &N Bsp   gzip-9-F ${rootfs_out_dir}/${type_initramdisk}         ${uboot_out_dir}/

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.