如何理解 mount 含义

如果想要使用某个外在的设备,或者使用某大页内存文件,我们经常需要对外设或者大页内存文件做 mount 操作。
那么 mount 的含义是什么,为什么需要 mount ?
在 Linux 系统中,一切都是文件,包括外在设备。要访问设备,就需要将文件与我们的文件树关联起来。在 Linux 中所有的文件都被组织在一个树形目录下,根目录是 '/' 。新加入的设备要想能被正常访问,就要将设备放在目录树的某个目录下,这就是通过 mount 实现的。

参考:
https://unix.stackexchange.com/questions/3247/understanding-mount-as-a-concept-in-the-os

As fschnitt points out, a comprehensive answer to this would likely be a chapter in a systems administration manual, so I'll try just to sketch the basic concepts. Ask new questions if you need more detail on specific points.
In UNIX, all files in the system are organized into a single directory tree structure (as opposed to Windows, where you have a separate directory tree for each drive).
There is a "root" directory, which is denoted by /, which corresponds to the top directory on the main drive/partition (in the Windows world, this would be C:). Any other directory and file in the system can be reached from the root, by walking down sub-directories.
How can you make other drives/partitions visible to the system in such a unique tree structure? You mount them: mounting a drive/partition on a directory (e.g., /media/usb) means that the top directory on that drive/partition becomes visible as the directory being mounted. Example: if I insert a USB stick in Windows I get a new drive, e.g., F:; if in Linux I mount it on directory /media/usb, then the top directory on the USB stick (what I would see by opening the F: drive in Windows) will be visible in Linux as directory /media/usb. In this case, the /media/usb directory is called a "mount point".
Now, drives/partitions/etc. are traditionally called "(block) devices" in the UNIX world, so you always speak of mounting a device on a directory. By abuse of language, you can just say "mount this device" or "unmount that directory".
I think I've only covered your point 1., but this could get you started for more specific questions.
Further reading: * http://ultra.pr.erau.edu/~jaffem/tutorial/file_system_basics.htm

你可能感兴趣的:(如何理解 mount 含义)