This is a question from the programmer's quiz community stackexchange.com.
Can someone explain to me why Linux's file system is a "single directory hierarchy tree" structure, unlike Windows that has a C: \, D: \ partition what, there is no special reason for doing so?
A word answer: not partitioned, Windows that is for backward compatibility.
Doug O'Neal 163 votes
Speaking of Unix, the file system is much older than Windows, so your question needs to be changed to "Why does Windows have to figure out a hard disk partitioning code?"
An advantage of a tree-like file structure is that any subdirectory or file can be found along the root, so if you need to migrate your local files to a networked hard drive, then the software will not notice Any difference
Assuming you have a system that has an operating system that can not be soldered but has a program that has high I / O requirements, you can easily load the / usr directory as read-only and / opt (the application installation directory ) Directory is loaded onto an SSD. This entire file system structure for the operating system has not changed.
However, under Windows, this problem is more annoying, especially in front of the program path with a C: \ Program Files \ ...
Gilles 70 votes
This is all for historical reasons, partly because doing so was more effective at the time.
Multics
Multics is the first operating system in my history known as a "hierarchical tree file structure," a mechanism in which a directory contains embedded subdirectories. Citing the words of RC Daley and PG Neumann in "A General-Purpose File System For Secondary Storage":
The second part of the paper elaborates on a file system of "hierarchical tree file structure", which is very efficient for the operating system. This structure balances the reliability and flexibility ...
For ease of understanding, we can think of this structure as a tree, a tree of files, and some of the directories are actually files. But there is an exception to the directory, its own pointer points to only a single, certain directory, then Root directory. It is not explicitly pointed to by other directories. The Root directory just implicitly represents a virtual branch. We call this branch a "file system."
At any time, users are in a directory, we call it "working directory", the user can access the file under the working directory by specifying the entry, and multiple users can work under the same working directory .
In every other area, Multics pursues flexibility by allowing users to work on one branch of the entire file system while leaving others unimportant, but also ensuring the ease of managing the files with the directory. Directories are also used to control access - the READ attribute of the directory allows users to access files in the directory, while the EXECUTE attribute allows users to modify files in the directory (this feature is inherited by later unix systems).
Multics also followed the design principle of "single storage object pool", but the paper is not in this area. "A single pool of storage objects" was a good fit for the hardware at the time, when there was no removable hard drive, at least no one cares about it. Multics does have an alternate backup storage pool, but it does not exist for users.
Unix
Unix systems are heavily influenced by Multics, but Unix is more focused on enhancing the "simplicity" of the system than Multics' agility.
The "single directory tree level" file system is very suitable for Unix systems. Just as with Multics, the details of a storage pool often do not require user care, but later came a detachable hard drive that Unix exposed to the user through the mount and umount commands (only users with "admin rights" In order to perform such an operation). In The Unix Time-Sharing System, Dennis Ritchie and Ken Tompson explain:
Although system root directories are generally on the same storage device, it is not necessary for other branch directories. For two reasons, we need to mount command to complete the work of the storage device mount: file name consistency of ordinary files, and storage devices where the file is located may have its own file storage structure. With the mount command, you can replace the previous file with a complete directory structure on a removable storage device. In fact, the mount command replaces a portion of the file hierarchy with a new one by referencing the external data. So for the entire file system before, there is no change.
In fact, take our system installation process example, the root directory has always accounted for a small piece of our hard disk, but other user data on different hard drives, through the mount mechanism, according to the sequence load to form an initialized system. A "mountable" system is done entirely by reading and writing special files. Various applications can create their own file system, or simply copy a copy from elsewhere. (Note: The central idea of the above text is that in UNIX everything is a file.)
Another advantage of Hierarchical Tree File System is that you can hand over the complex tasks of managing storage devices to the kernel, which means that although the kernel is getting more and more complicated, the result of building the application Is to keep simple, because the kernel has been very dirty work package, most applications do not have to care about this part of the details, this is a more natural design.
Windows
Windows runs two ancient bloodstreams: the VMS operating system designed to run on the VAX microcomputer and the CP / M operating system running on earlier Intel microcomputers such as the 8080 and the Z80.
VMS has a distributed, hierarchical file system called Files-11. In Files-11, the full path to a file includes a Node Name, an associated user account, device name, directory tree, file name and file type, and version number. VMS has a powerful Logical Names feature that allows custom "shortcuts" to the specified path, so users do not need to worry about the "real" path to the directory.
CP / M is designed for 64KB memory and floppy system. For the sake of simplicity, there is no concept of "directory" since birth, but files are accessed by reference to "drive location", such as A: or B :.
MSDOS 1.0 inherits this feature of CP / M, so after MSDOS 2.0 introduced the concept of "Directories," the "drive letter" character was retained before the path for compatibility with 1.0, and the slash "/" sign was used by the original VMS and CP / M system, said the "command parameters start" symbol, so later DOS and Windows must be distinguished, and the backslash "\" symbol as a path separator.
Windows inherited the DOS and VMS habits, although it has little meaning, but still retains the "drive letter" of the tradition. Nowadays, the UNC path (the naming convention for \ servername \ sharename) is used at the bottom of Windows, but this is just some of the features that advanced Windows users need to know, and Windows does now come with "Reparse Points" Hanging on storage (so do not need C: such drive letter).