Several ways to Mount Rootfs on Linux startup

Source: Internet
Author: User

There are many questions about the process of mounting the root file system on Linux startup, and today we found useful information in the water and wood essence area, excerpt as follows:

1, Linux boot, after a series of initialization, the Mount root file system is required for the final run of the Init process, such as preparation, mount root file system There are several ways:

1) The file system already exists on a partition of the hard disk (or similar device), and kernel directly to mount based on the command line parameters (ROOT=/DEV/XXX) that are started. Here is a question, in the case of the root filesystem itself does not exist, kernel how to find the corresponding device according to/DEV/XXX? Note: The Mount method of the root file system and other file systems is not the same, kernel by directly resolving the name of the device to obtain the main, From the device number, you can then access the corresponding device driver. So there is a long string of root_dev_names (such as hda,hdab,sda,sdb,nfs,ram,mtdblock ...) in the INIT/MAIN.C, which can be used to get the device number according to the device name. Note that the boot parameter (root=/dev/xxx) set in the bootloader or kernel is just a code name, and the actual root file system does not necessarily exist in this device file!

2) Mount the root file system from a slow device such as a floppy drive, and if kernel supports RAMDisk, when loading the root filesystem, the kernel determines that the file system image will be copied to RAMDisk automatically if it needs to be mounted from a floppy disk (FDX) mount (root=/dev/fd0). The generic counterpart device Ram0, and then mount the root file system on the RAM0. From the source, if kernel compile without support RAMDisk, and start parameter is ROOT=/DEV/FD0, the system will be directly on the floppy disk mount, in addition to the speed is relatively slow, theoretically feasible (did not try, do not know is this?)

3) Use INITRD to mount the root file system at startup. Note that the two concepts of RAMDisk and INITRD, in fact RAMDisk is just a block device implemented in RAM, similar to the hard disk operation, but with faster read and write speed, it can be used at any time when the system is running, not just for booting; INITRD (boot Loaderinitialized RAMdisk) can be said to be used in the startup process of a mechanism, the specific implementation process also uses RAMdisk technology. Just before loading Linux, bootloader can load a small root file system image to a specified location in memory, let's call this memory initrd (here is the memory of INITRD, not ramdisk, note the difference), The bootloader then tells the kernel initrd the starting address and size by passing the parameters (which can also be compiled into the kernel) and temporarily uses INITRD to mount the root filesystem during the boot phase. The original purpose of INITRD was to divide the boot of kernel into two phases: keep the least basic startup code in kernel, and then put support for a variety of hardware devices in a modular way in INITRD, This allows the required modules to be loaded from the root file system mount of INITRD during the boot process. One of the benefits of this is that you can flexibly support different hardware by modifying the content in the initrd while keeping the kernel intact. The root file system can be re-mount to other devices at the end of the startup process, but it can no longer be re-mount (as many embedded systems do). INITRD implementation process is this: bootloader the root file system image to the memory specified location, the relevant parameters passed to the kernel, the kernel starts to copy the contents of the INITRD into the RAMDisk (RAM0), the INITRD occupied memory released, Mount the root file system on the RAM0. As you can see from this process, the kernel needs to support both the RAMDisk and the INITRD (this need is all programmed into the kernel and not as a module).

2, embedded system root file System implementation method: for kernel and root file system are stored in the flash system, generally can take advantage of the Linux boot initrd mechanism. The specific process is already clear before, there is a point is to pass the ROOT=/DEV/RAM0 in the boot parameters, so that the INITRD mount root file system is no longer switching, because this time the actual device is RAM0. There is the INITRD start address parameter is the virtual address, need and bootloader with the physical address corresponding.

Several ways to Mount Rootfs on Linux startup

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.