After reading 1, know the structure and function of the root file system. After reading 2, know kernelMountthe actual process of the root file system.
1. Elaborate the root file system http://fangjian0518.blog.163.com/blog/static/5591965620112171420757/
What is a root file system? When Linux boot starts, the file system that is used by default is the root file system.
The device that holds the file system is the file system device. For example, for a typical Windows 2000 operating system, the hard disk C drive is the filesystem device, and the files on the hard disk that are stored in a certain rule form a file system, and Windows 2000 has a file system such as NTFS or FAT32.
When we enter LS/in Linux, we see that the directory structure and content in these directories are very similar, because all Linux distributions follow the FHS standard recommendations for the root filesystem layout.
This standard specifies the name of each subdirectory under the root directory and what it holds:
Directory Name |
What to store |
/bin |
Required user commands, such as LS, CP, etc. |
/sbin |
Prerequisite system administrator commands, such as ifconfig, reboot, etc. |
/dev |
Device files, such as Mtdblock0, tty1, etc. |
/etc |
System configuration files, including boot files, such as Inittab, etc. |
/lib |
Necessary link libraries, such as C-link libraries, kernel modules |
/home |
Normal User home Directory |
/root |
Root User home Directory |
/usr/bin |
Non-essential user programs, such as Find, Du, etc. |
/usr/sbin |
Non-essential administrator programs, such as chroot, inetd, etc. |
/usr/lib |
Library files |
/var |
Variables stored by daemons and utility programs, such as log files |
/proc |
A virtual file system used to provide kernel and process information that is automatically generated by the kernel in the directory |
/sys |
A virtual file system used to provide kernel and device information that is automatically generated by the kernel in the contents of the directory |
/mnt |
File system mount point for temporary installation of file systems |
/tmp |
Temporary files that will be automatically cleared after reboot |
FHS (Filesystem Hierarchy Standard)
2. linux--root file system mount Process analysis http://blog.csdn.net/guopeixin/article/details/5962482
Simply put, the root filesystem includes the virtual root file system and the real root file system. In the initial phase of kernel startup, we first create the virtual root filesystem, then call Do_mount to load the real filesystem and switch the root filesystem to the real filesystem, which is the real file system. After the real root filesystem is mounted, the initialization program in the file system is executed.
Run_init_process ("/sbin/init");
Run_init_process ("/etc/init");
Run_init_process ("/bin/init");
Run_init_process ("/bin/sh");
...
3. Common sense:
The mechanism of PS is to get process information by looking at the contents of/proc, there is mount-t proc None/proc in/etc/init.d/rcs.
Linux/proc/devices and/dev difference http://www.chinaitlab.com/embed/linux/876632.html
Q: What is the difference between the content in the/dev/directory and the content in the/proc/file devices under the Linux environment? When I was doing experiments on the target board, I found that when I loaded the driver module into the board, there was a change in the devices file, and the/dev did not change at all,/dev/is not also the device contact, why is the module set up the device contact,/dev/under the change?
The device in/proc/devices/is loaded into the kernel by Insmod, which produces a major for Mknod as a parameter.
/dev/*.* is by Mknod plus go, format: Mknod Device1 c/b Major minor such as: Mknod DR1 C 254 0, the user through this device name to access your driver.
Device file, device number #ll-A/dev in each line you can see the device file, device number (primary, secondary)
For each hardware device, the system kernel has the appropriate device driver responsible for handling it. In Unix, a device file is used to represent a hardware device, and each device driver is abstracted into the form of a device file, giving the application a consistent file interface that facilitates communication between the application and the operating system.
As a rule, all device files are placed in the/dev directory.
Embedded: Root file system