简体   繁体   English

操作系统如何支持多个文件系统?

[英]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 ). 对于一些操作系统(DOS)的前缀可能是设备的字母(例如C:\\在开始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 ). 对于其他操作系统,它可能看起来像文件路径的正常部分(例如/home /home/foo/bar.txt/开头的/home可能告诉操作系统该文件位于/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 ). 一旦操作系统弄清楚哪个文件系统包含该文件,它就可以使用文件的“全局名称”的剩余部分向文件系统询问该文件(例如,对于文件/home/foo/bar.txt它会询问安装在/home文件系统,用于文件/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). 通常(但并非总是),这被称为“虚拟文件系统”(或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 ). 这可以包括自动检测(例如,来自存储设备上的分区表条目),用于可移动介质的一组规则,和/或配置文件( /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. 对于文件系统,操作系统必须实现转换系统,该转换系统将文件的虚拟块N转换为磁盘上的逻辑块Q.

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. 大多数操作系统都有某种MOUNT命令,它告诉操作系统连接到磁盘并确定它具有哪种文件系统。 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. 在这些日子里,除了磁盘之外,还有9轨磁带和自己的文件系统。 The operating system had to support those as well. 操作系统也必须支持这些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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