简体   繁体   中英

How can an operating system can support multiple file systems?

I can't seem to find an answer to this question. I'd just like to understand how one single OS can implement and run (support) multiple file systems?

Assume that there's a global name-space where all file and directory names have some sort of prefix to determine which file system the file or directory is from. For some operating systems (DOS) the prefix might be a device letter (eg the C:\\ at the start of C:\\foo\\bar.txt ). For other operating systems it might look like a normal part of the file's path (eg the /home at the start of /home/foo/bar.txt/ might tell the OS that the file is in the file system mounted at /home ).

Once the OS has figured out which file system contains the file it can ask that file system about the file using the remaining part of the file's "global name" (eg for the file /home/foo/bar.txt it'd ask the file system mounted at /home for the file /foo.bar.txt ).

To allow this to work there will be a layer built into the OS to register file systems and figure out which file system to ask about which file or directory (likely in addition to providing other features - eg caching directory info and file data). Often (but not always) this is called "the Virtual File System" (or VFS).

During boot, and when a new storage device is plugged in, there will be "something" to figure out which type of file system to use and how it will be added to the global name space. This can include auto-detection (eg from partition table entries on the storage device), a set of rules for removable media, and/or a configuration file ( /etc/fstab ).

The basic function of a file system is to provide the mapping to translate virtual blocks into logical blocks (or in ye olde days, physical blocks). For a file system, the operating system has to implement a translation system that will convert virtual block N of a file into logical block Q on the disk.

There is nothing that prevents an operating system from having multiple subsystems for performing that translation in different ways corresponding to multiple file systems.

Most operating systems have some kind of MOUNT command that tells the operating system to connect to a disk and determine what kind of file system it has. It is during the mount process that the operating system selects the appropriate virtual to logical translation software to use.

Operating system has supported multiple file systems from the beginning. In ye olde days, there were 9-track tapes with their own file systems in addition to disks. The operating system had to support those as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM