share mounts

转载 2012年03月27日 14:36:57

7.2.3. Sharing Mounts

Occasionally, certain system administration tasks require access to the same file system from more than one place in the directory tree (for example, when preparing a chroot environment). This is possible, and Linux allows you to mount the same file system to as many directories as necessary. Additionally, the mount command implements the --bind option that provides a means for duplicating certain mounts. Its usage is as follows:
mount --bind old_directory new_directory
Although this command allows a user to access the file system from both places, it does not apply on the file systems that are mounted within the original directory. To include these mounts as well, type:
mount --rbind old_directory new_directory
Additionally, to provide as much flexibility as possible, Red Hat Enterprise Linux 6 implements the functionality known as shared subtrees. This feature allows the use of the following four mount types:
Shared Mount
A shared mount allows the creation of an exact replica of a given mount point. When a mount point is marked as a shared mount, any mount within the original mount point is reflected in it, and vice versa. To change the type of a mount point to a shared mount, type the following at a shell prompt:
mount --make-shared mount_point
Alternatively, to change the mount type for the selected mount point and all mount points under it, type:
mount --make-rshared mount_point
Example 7.4. Creating a Shared Mount Point
There are two places where other file systems are commonly mounted: the /media directory for removable media, and the /mnt directory for temporarily mounted file systems. By using a shared mount, you can make these two directories share the same content. To do so, as root, mark the /media directory as shared:
~]# mount --bind /media /media
~]# mount --make-shared /media
Then create its duplicate in /mnt by using the following command:
~]# mount --bind /media /mnt
It is now possible to verify that a mount within /media also appears in /mnt. For example, if the CD-ROM drive contains non-empty media and the /media/cdrom/ directory exists, run the following commands:
~]# mount /dev/cdrom /media/cdrom
~]# ls /media/cdrom
EFI  GPL  isolinux  LiveOS
~]# ls /mnt/cdrom
EFI  GPL  isolinux  LiveOS
Similarly, it is possible to verify that any file system mounted in the /mnt directory is reflected in /media. For instance, if a non-empty USB flash drive that uses the /dev/sdc1 device is plugged in and the /mnt/flashdisk/ directory is present, type:
~]# mount /dev/sdc1 /mnt/flashdisk
~]# ls /media/flashdisk
en-US  publican.cfg
~]# ls /mnt/flashdisk
en-US  publican.cfg

Slave Mount
A slave mount allows the creation of a limited duplicate of a given mount point. When a mount point is marked as a slave mount, any mount within the original mount point is reflected in it, but no mount within a slave mount is reflected in its original. To change the type of a mount point to a slave mount, type the following at a shell prompt:
mount --make-slave mount_point
Alternatively, it is possible to change the mount type for the selected mount point and all mount points under it by typing:
mount --make-rslave mount_point
Example 7.5. Creating a Slave Mount Point
This example shows how to get the content of the /media directory to appear in /mnt as well, but without any mounts in the /mnt directory to be reflected in /media. As root, first mark the /media directory as shared:
~]# mount --bind /media /media
~]# mount --make-shared /media
Then create its duplicate in /mnt, but mark it as slave:
~]# mount --bind /media /mnt
~]# mount --make-slave /mnt
Now verify that a mount within /media also appears in /mnt. For example, if the CD-ROM drive contains non-empty media and the /media/cdrom/ directory exists, run the following commands:
~]# mount /dev/cdrom /media/cdrom
~]# ls /media/cdrom
EFI  GPL  isolinux  LiveOS
~]# ls /mnt/cdrom
EFI  GPL  isolinux  LiveOS
Also verify that file systems mounted in the /mnt directory are not reflected in /media. For instance, if a non-empty USB flash drive that uses the /dev/sdc1 device is plugged in and the /mnt/flashdisk/ directory is present, type:
~]# mount /dev/sdc1 /mnt/flashdisk
~]# ls /media/flashdisk
~]# ls /mnt/flashdisk
en-US  publican.cfg

Private Mount
A private mount is the default type of mount, and unlike a shared or slave mount, it does not receive or forward any propagation events. To explicitly mark a mount point as a private mount, type the following at a shell prompt:
mount --make-private mount_point
Alternatively, it is possible to change the mount type for the selected mount point and all mount points under it:
mount --make-rprivate mount_point
Example 7.6. Creating a Private Mount Point
Taking into account the scenario in Example 7.4, “Creating a Shared Mount Point”, assume that a shared mount point has been previously created by using the following commands as root:
~]# mount --bind /media /media
~]# mount --make-shared /media
~]# mount --bind /media /mnt
To mark the /mnt directory as private, type:
~]# mount --make-private /mnt
It is now possible to verify that none of the mounts within /media appears in /mnt. For example, if the CD-ROM drives contains non-empty media and the /media/cdrom/ directory exists, run the following commands:
~]# mount /dev/cdrom /media/cdrom
~]# ls /media/cdrom
EFI  GPL  isolinux  LiveOS
~]# ls /mnt/cdrom
~]#
It is also possible to verify that file systems mounted in the /mnt directory are not reflected in /media. For instance, if a non-empty USB flash drive that uses the /dev/sdc1 device is plugged in and the /mnt/flashdisk/ directory is present, type:
~]# mount /dev/sdc1 /mnt/flashdisk
~]# ls /media/flashdisk
~]# ls /mnt/flashdisk
en-US  publican.cfg

Unbindable Mount
In order to prevent a given mount point from being duplicated whatsoever, an unbindable mount is used. To change the type of a mount point to an unbindable mount, type the following at a shell prompt:
mount --make-unbindable mount_point
Alternatively, it is possible to change the mount type for the selected mount point and all mount points under it:
mount --make-runbindable mount_point
Example 7.7. Creating an Unbindable Mount Point
To prevent the /media directory from being shared, as root, type the following at a shell prompt:
~]# mount --bind /media /media
~]# mount --make-unbindable /media
This way, any subsequent attempt to make a duplicate of this mount will fail with an error:
~]# mount --bind /media /mnt
mount: wrong fs type, bad option, bad superblock on /media,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail  or so


转自http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/sect-Using_the_mount_Command-Mounting-Bind.html

关于 /proc/mounts

现在的 Linux 系统里一般都有这么三个文件:/etc/fstab,/etc/mtab,和 /proc/mounts,比较容易让人迷惑。简单解释一下。 This file provides a l...
  • skypeGNU
  • skypeGNU
  • 2013年10月30日 11:35
  • 6013

umount /** was not found in /proc/mounts

mount nfs后, 如果遇到服务器修改 /etc/exports 等原因时,经常会遇到 umount2: Stale NFS file handle  umount: htdocs: S...
  • myweishanli
  • myweishanli
  • 2014年04月20日 15:00
  • 5773

/proc/mounts和/etc/mtab的区别

3.2.22. /proc/mounts This file provides a list of all mounts in use by the system: rootfs / ...
  • loryliu
  • loryliu
  • 2014年05月18日 11:11
  • 779

[小技巧] NFS mount 后无法 unmount 问题解决

问题:umount 时发生如下错误: $ sudo umount /mnt/ /mnt was not found in /proc/mounts /mnt was not found in /...
  • robertsong2004
  • robertsong2004
  • 2014年11月21日 11:47
  • 7773

利用/proc/mounts检查已经被系统挂载的设备

1 介绍/proc/mounts 如何利用/proc/mounts知道已经挂载上的设备呢,我们先来看看/proc/mounts都有啥东西 解释一下,第一列是设备路径,比如说/dev/sda1 ...
  • zhouzhenhe2008
  • zhouzhenhe2008
  • 2017年06月08日 20:38
  • 1212

/etc/mtab与/proc/mounts

现在的 Linux 系统里一般都有这么三个文件:/etc/fstab,/etc/mtab,和 /proc/mounts,比较容易让人迷惑。简单解释一下。 This file provides a li...
  • taiyang1987912
  • taiyang1987912
  • 2015年01月07日 14:55
  • 5133

Linux中/etc/fstab /etc/mtab /proc/mounts这三个文件的分析与比较

本文主要讲解Linux中/etc/fstab /etc/mtab /proc/mounts这三个文件的作用以及不同之处。 转自http://haohaozhang.blog.51cto.com/...
  • Jonathan158
  • Jonathan158
  • 2017年04月10日 13:42
  • 859

ORA-01105: mount is incompatible with mounts by other instances

Oracle 11G R2 RAC环境 今天启动其中一个节点报错,提示如下: ORA-01105: mount is incompatible with mounts by other insta...
  • gHost241
  • gHost241
  • 2011年11月10日 09:57
  • 2503

Recovery流程

OTA流程如下: 1.       根据OTAService功能,选择update.zip更新包更新 2.       系统重启进入recovery命令 3.       执行升级命令 4. ...
  • lijinwei_123
  • lijinwei_123
  • 2013年06月13日 15:23
  • 1409

oracle 11g rac ORA-01105: mount is incompatible with mounts by other instances

[oracle@node1 ~]$ export ORACLE_SID=shark1 [oracle@node1 ~]$ sqlplus / as sysdba SQL*Plus: Relea...
  • ZengMuAnSha
  • ZengMuAnSha
  • 2013年08月23日 10:23
  • 3470
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:share mounts
举报原因:
原因补充:

(最多只允许输入30个字)