Original address: http://blog.csdn.net/neiloid/article/details/6938781
Root file system: English should be root filesytem, but sometimes it is simply called file system. In fact, we refer to the previous section of the Linux system required to run some of the files, the command composed of the entire file directory structure.
Ø file system: The English language should be either file systems or Filesytem, which means a way to facilitate the management of files storage and data organization. For example, under Windows Fat, FAT32, ntfs,linux under the Ext2,ext3,nfs, and so on, these should all belong to this concept.
So the root file system and file system are two concepts, please do not misunderstand, for the sake of understanding, the reader can understand the file system as the root file system stored in the format of the disk.
RFS and FS"File System" and "Root file System".
Or we will unify the abbreviation for FS and RFS:
FileSystem: File system => FS;
Root filesystem: Root file System => RFS.
First, you consider a description statement: The root file system is also a "file system", can be considered as a "special" "File System", why is it called "special" it. Because this "root" file system is loaded with some "special features" (in fact, the "file system") all have the same functionality, that is, "operating system" may need some sort of "layout" to manage related devices, such as floppy disk devices, hard disk devices, virtual disk devices, and so on, This may be the use of a defined "data structure" of the "layout", that is, "file system", and the emergence of "root file System" may be used to play a major or important role.
(Image point, Windows under the C disk partition is a certain file system, such as FAT32, NTFS, which is also a file system, of course). When you install the Windows operating system, you will be asked to "format" C disk first [of course we currently consider the operating system is installed in C disk], the adoption of a "file system" such as NTFS, FAT32, etc., this step is similar to the installation of "root file System", That is, the NTFS file system in C disk is called the "root file System". The NTFS file system in the D disk is called the "file system" or you want to prefix the name or not, such as "Ordinary file system", and we say from the name, because there is a word "root", So we have two names of the name, Nature is FS and RFS, so this name will make people feel very "foggy", and then "unintelligible", the "format" process is the C disk storage space on the predefined one of the FS "Data structure" to "initialize" these disks, [This assumes that Minix FS can also be used by Windows to "format" C disk] such as building a boot block, building super blocks, building two kinds of bitmap blocks, building I-node bitmap blocks, building data blocks, etc. in other words, the disk partition must have the disk space "organized" in a certain data structure, To "some kind of system" (OS or FS, it seems to be more accurate than FS. It can "access" the partition, so there are two distinctions in the 0.11 kernel: mount_root () and Sys_mount (), respectively, "Mount Root file System", "Mount File System" [ I don't think I should use one word here: Install. What I understand is that "installation" means to "put" something on top of something else, for example, if you want to install some kind of software to C disk, this software installation program may be in D, then you will start D disk the Software installation program, and then the installation program will install the software by default to C disk, so this process will be called "Installation", before the installation of the C disk without any information on the software, after the installation of C disk will have the software information! So, to use the Sys_mount () feature, a device (specifically a partition) must have been "installed" in some sort of FS format before the device is "mounted" ( Mount) to "a place" to go.
So let's analyze it with Minix FS and Fat FS.
In 0.11 kernel code, the comment from mount_root (void) indicates that the function is invoked by the system call function Sys_setup () and the function Sys_setup () is invoked when the system is initialized for setup. Why not Call Sys_mount ()? And when do we use the Sys_mount () function? In fact, the Sys_mount () function is also called the system call function. In the Linux system, when you enter the mount in the command line of a shell, you will see the following message:
Mount:usage:mount Dev dir
You should probably be clear, and this is the "correct cue", because we use the wrong mount usage (in addition, in the/bin directory, you can see the mount such a file, mount should be a separate program:-), many places say mount is shell internal command, And I'm more likely to think that CDs is one of the shell's internal commands.
So we can tell from the annotation of the Sys_mount () function, this function is "Install File system call function" (I personally think this sentence is not very good understanding), and I know the function of function, so I would like to understand: This function is a "system call function", its function is "a ' file system ' that FS ' Mount ' to (existing ' root file system ' that is RFS) a "directory", that is, the directory file I node. So, this corresponds to the hint message "Mount Dev dir"; Also, we need to know that Dev represents a partition on a device, and Dir represents a "catalog file" in an "existing" file system, and note that it must be "existing", Here is what we call the "root file system", so if you want to use the Mount feature, you have the following conditions:
1, under an existing "File system" (Root file system RFS)
2, the RFS has some equipment files exist, such as/dev under the hd0,hd1, and so on
The/dev in 3, 2 is actually managed by RFS.
4, also need to have a directory exists, and the directory is in the RFS that is managed by RFS
5, of course you have to have the actual disk device exists (/dev/hd0 only represents a "virtual" device file name) and the device has been "FS" format
6. In the end you will mount Dev dir to "mount" the actual disk partition into Dir
If you have a hard drive (assuming the size is 512MB), is just a partition, the FS in the partition is FAT FS (assuming UNIX can access directly, the big deal is considered to be the same as Minix FS, but the name is different, the following is to see it as a Minix FS to analyze).
So when you start the "0.11 system" (this is a simpler version, the meaning is that you entered the SH command line, in fact RFS has been "automatic" "Mount" Good (is Mount_root ()), at this time, you need in the "0.11 system" to access that hard disk, Suppose you have installed the hard drive on the hardware, and then you will be in the SH command line "Installation" process, if it is:
Mount/dev/hd0/mnt/fatc
The first partition of the first hard disk (currently only one partition) is "mounted" to the FATC directory in the MNT directory under the root directory in "RFS". So, you can just "go" to the FATC directory to access the files in the hard drive.
It worked. Mount success.
Because you understand the kernel code, you should know how to mount a series of processes, and you need to know the following points:
1,/dev/hd0,/MNT/FATC are RFS in the "file" (collectively), the former is a device file, the latter is a directory file.
[Embodied in the I-node structure, where the respective inode->i_mode distinguishes between "Device type Files" or "Directory type Files", and the former inode->zone[0] contains the device number (and Inode->i_dev is also the device number), But the actual meaning is not the same), the latter's inode->i_mount is placed, note that because this I node is a "installed"/"mount" good fs of the I node]
2,/This is the directory, but this is the RFS directory, and is the root directory.
3,/MNT/FATC "equivalent" is that hard disk partition FS in the root directory. But actually the root directory on the hard drive is also/.
[Suppose you go to the "root" directory of that partition (in fact), but can you just go in there? A file in the hello.c, you will be in the existing SH command line, CD/MNT/FATC carriage return after LS hello*-L, and then you will find hello.c this file, in fact you should need to know RFS is how to "positioning" To find the hello.c file, there is an important process is to take the inode information of each file that is the Iget () function, the function found in the inode->i_mount of a file is placed, "special care", why. Because the inode represents being "mounted" on a file system, RFS will "switch" to that fs root directory (using parameters such as Root_ino,super_block[i].s_dev), and then continue to search for the required files in the FS as normal process, So you can find it.
"Normal process" means either to start looking for files from an FS root directory or to start looking for files from the current working directory of a filesystem's current user process.
So there's an important argument (that I understand): file access across the file system. This process involves a wide range of major data structures are: I node, super block.
4, finally, when you do not need to use the partition or you want to take away the hard drive, you will use the Umount function, which corresponds to Sys_umount () This "system call function", then you need to know what the function did.
Finally, in general:
Mount_root () mount a Minix FS is also known as RFS.
You can then mount another FS in the RFS. RFS and the system "to survive", automatically "mount", automatically be "unloaded."
Therefore, fat can also be a root file system, of course, is also a file system.
So, when you install more than one operating system on your computer, assume that in the C disk (FAT32 FS) was installed in Win98, in D disk (NTFS FS) was mounted WinXP, then, when you enter the Win98, you FAT32 as if RFS, then NTFS is FS When you enter the WinXP, NTFS seems to be RFS, then FAT32 is FS.
(why C disk is to FAT32, because Win98 does not support NTFS FS, and you are installed Win98)