There have been many questions about the process of mounting the root file system when Linux starts. Today, useful information was found in the Shuimu Essence area, excerpted as follows:
1. When Linux starts, after a series of initializations, you need to mount the root file system to prepare for the last run of the init process. There are several ways to mount the root file system:
1) The file system already exists on the hard disk ( Or a similar device) on a partition, the kernel directly mount according to the command line parameters (root=/dev/xxx). Here is a problem, in the case that the root file system itself does not exist, how does the kernel find the corresponding device according to /dev/xxx? Note: The mount mode of the root file system and other file systems is different. The kernel obtains the master and slave device numbers of the device by directly parsing the name of the device, and then accesses the corresponding device driver. So in init/main.c there is a long string of root_dev_names (such as hda, hdab, sda, sdb, nfs, ram, mtdblock… …), through which you can get the device number based on the device name. Note that the bootloader or the boot parameter set in the kernel (root=/dev/xxx) is just a code name. The device file does not necessarily exist in the actual root file system!
2) Load the root file system from a slower device such as a floppy disk drive. If the kernel supports ramdisk, when the root file system is mounted, the kernel determines that it needs to mount from the floppy disk (fdx) (root=/dev/fd0) ), it will automatically copy the file system image to the ramdisk, generally corresponding to the device ram0, and then mount the root file system on ram0. From the source code, if the kernel does not support ramdisk when compiling, and the startup parameter is root=/dev/fd0, the system will mount directly on the floppy disk, except that the speed is slow, theoretically feasible (not tried, I don’t know Not like this?)
3) Use initrd to mount the root filesystem at boot time. Pay attention to the two concepts of ramdisk and initrd. In fact, ramdisk is just a block device implemented on ram. It is similar to hard disk operation, but has faster read and write speed. It can be used at any time during system operation, not just Initrd (boot loader initialized RAM disk) can be said to be a mechanism used in the startup process, the specific implementation process also uses ramdisk technology. Just before loading Linux, the bootloader can load a relatively small root file system image in a specified location in memory, and call this memory initrd (here is the memory occupied by initrd, not ramdisk, pay attention to the difference ), then the bootloader tells the kernel the start address and size of the initrd by passing arguments (you can also compile these parameters in the kernel), and you can temporarily use the initrd to mount the root filesystem during the boot phase. The original purpose of initrd is to divide the startup of the kernel into two phases: keep the minimum basic startup code in the kernel, and then put the support for various hardware devices in the initrd as a module, so that The required modules can be loaded from the root file system where initrd is mounted during startup. One of the benefits is that you can flexibly support different hardware by modifying the contents of the initrd while keeping the kernel unchanged. At the end of the boot process, the root file system can be remounted to other devices, but it can be remounted (this is the case with many embedded systems). The specific implementation process of initrd is as follows: the bootloader loads the root file system image into the specified location of the memory, and passes the relevant parameters to the kernel. When the kernel starts, the contents of the initrd are copied to the ramdisk (ram0), and the memory occupied by the initrd is used. Released, mount the root file system on ram0. As you can see from this process, the kernel needs support for both ramdisk and initrd (this need is programmed into the kernel and cannot be used as a module).
2. An implementation method of the embedded system root file system: for the kernel and the root file system are stored in the flash system, generally can use the mechanism of the initrd initiated by linux. The specific process has been relatively clear. Another point is to pass root=/dev/ram0 in the startup parameters, so that the root file system mounted by initrd is no longer switched, because the actual device at this time is ram0. There is also a starting address parameter of initrd as a virtual address, which needs to correspond to the physical address used in the bootloader.
We know that both functions provide the ability to enter one line at a time. However, gets is a depr
Engaged in two years WindowsClient development, what multi-threading, multi-process development, ha
Linux has created a friendly environment that gives us the possibility to choose. For example, most
When we write the shell, there will be such a scene: For example: I want to back up the passwd fil
Memcache installation under Linux (with libevent installation) Tutorial
Linux SSHD client Chinese garbled solution
Solution for Starting ONTRACK (DDO) message each time it starts up
Linux does not start properly. Solution
Linux installation tslib-1.4 error and solution
How to enable dhcp relay to assign IP
Centos boot automatically starts the SSHD service command
Top Ten Issues to Protect Windows Servers
Xeon processor IBM System x3500 priced at 14300
Windows7 system top ten combination shortcuts operation skills
When is the official version of Win10 Server? 2016 win10 official version will be released
My computer for windows7 system can not
Win7/Win8.1 genuine serial number how to upgrade free win10
When shutting down, it always prompts that rundll32.exe can not be solved.
"Folder imitator" virus variant aimed at Win7 users