File system loading during Linux boot process

  

Foreword: I think my article is relatively simple. Some beginners can take a look, this is why I am not posting on the embedded version. For the master, if you don't take the time, hope can help me to see and give pointers to the mistakes. This is also the purpose of my coming here to communicate with you.

After the module driver is completed, the file system is mounted. I always thought: I compiled the kernel using the initrd mode, the device is loaded in the /linuxrc script under the RAM DISK file system, so a lot of time is wasted on this. However, I have a deeper understanding of initrd, and I will wait a minute. In fact, the first file system mounted by the kernel is root.cramfs in nand flash. The mount related code mount_root() is in the file /fs/super.c. Then mount the devcie file system under the /dev directory with the code mount_devfs_fs(). Because the noninitrd mode is used, the file system mount is complete, the init process continues down until it runs:

if (execute_command)execve(execute_command,argv_init,envp_init); here init switch Into another thread, the running program is defined in execute_command. Execute_command is the command line passed into vivi. You can see it during startup: Kernel command line: noinitrd root=/dev/bon/2 init=/linuxrc console=ttyS0 so execute_command corresponds to /linuxrc, so the program runs the script under the root directory. Linuxrc, in my system he corresponds: #!/bin/shecho "mount /etc as ramfs"/bin/mount -n -t ramfs ramfs /etc/bin/cp -a /mnt/etc/* /etcecho "re-create the /etc/mtab entries"/bin/mount -f -t cramfs -o remount,ro /dev/mtdblock/3 //bin/mount -f -t ramfs ramfs /etcexec /sbin/init I will not explain (the last is to start bash), you can mount root.cramfs under linux under /mnt to see the content to know:

mount –t cramfs –o loop root. Cramfs /mnt/cramfs here actually want to tell everyone, how do we implement the boot automatically load some running programs, now it should be very clear, write a script is OK. (In fact, I have been in the yy problem before) Finally, I will not talk about the principle of initrd (initail ram disk), clichés, and many online. I will understand my understanding that initrd contains some of the module drivers, which share the size of the kernel to a certain extent, because both of them must be loaded into the memory at the same time when starting up; therefore, more importantly, it can To ensure the portability of the kernel, as long as different initrd file systems are provided for different hardware platforms, the kernel can remain unchanged. Therefore, the main role of initrd is to load some complex platform-related hardware, such as SCSI hard drives, network card drivers (like diskless workstations, using nfs).

Copyright © Windows knowledge All Rights Reserved