mount --bind使用方法
mount --bind使用方法
从Linux 2.4.0开始,可以将文件系统的一部分(目录)重新挂载到其他地方。实现类似软连接的功能,然而又有别于软连接。
如下是mount命令关于bind挂载的官方手册,已经够详细了,我就不翻译了。
1 The bind mounts.
2 Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is
3 mount --bind olddir newdir
4 or shortoption
5 mount -B olddir newdir
6 or fstab entry is:
7 /olddir /newdir none bind
8
9 After this call the same contents is accessible in two places. One can also remount a single file (on a single file). It's also
10 possible to use the bind mount to create a mountpoint from a regular directory, for example:
11
12 mount --bind foo foo
13
14 The bind mount call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including sub‐
15 mounts is attached a second place using
16
17 mount --rbind olddir newdir
18
19 or shortoption
20
21 mount -R olddir newdir
22
23 Note that the filesystem mount options will remain the same as those on the original mount point.
24
25 mount(8) since v2.27 (backported to RHEL7.3) allow to change the options by passing the -o option along with --bind for example:
26
27 mount --bind,ro foo foo
28
29 This feature is not supported by Linux kernel and it is implemented in userspace by additional remount mount(2) syscall. This solu‐
30 tion is not atomic.
31
32 The alternative (classic) way to create a read-only bind mount is to use remount operation, for example:
33
34 mount --bind olddir newdir
35 mount -o remount,ro,bind olddir newdir
36
37 Note that read-only bind will create a read-only mountpoint (VFS entry), but the original filesystem superblock will still be
38 writable, meaning that the olddir will be writable, but the newdir will be read-only.
39
40 It's impossible to change mount options recursively (for example with -o rbind,ro).
关于mount命令的其他用法可以参考mount手册:http://www.jinbuguo.com/man/mount.html
永远年轻,永远热泪盈眶