Este conteúdo não está disponível no idioma selecionado.
4.12. Bind Mounts and Context-Dependent Path Names
GFS2 file systems do not provide support for Context-Dependent Path Names (CDPNs), which allow you to create symbolic links that point to variable destination files or directories. For this functionality in GFS2, you can use the
bind
option of the mount
command.
The
bind
option of the mount
command allows you to remount part of a file hierarchy at a different location while it is still available at the original location. The format of this command is as follows.
mount --bind olddir newdir
After executing this command, the contents of the
olddir
directory are available at two locations: olddir
and newdir
. You can also use this option to make an individual file available at two locations.
For example, after executing the following commands the contents of
/root/tmp
will be identical to the contents of the previously mounted /var/log
directory.
[root@menscryfa ~]#cd ~root
[root@menscryfa ~]#mkdir ./tmp
[root@menscryfa ~]#mount --bind /var/log /tmp
Alternately, you can use an entry in the
/etc/fstab
file to achieve the same results at mount time. The following /etc/fstab
entry will result in the contents of /root/tmp
being identical to the contents of the /var/log
directory.
/var/log /root/tmp none bind 0 0
After you have mounted the file system, you can use the
mount
command to see that the file system has been mounted, as in the following example.
[root@menscryfa ~]# mount | grep /tmp
/var/log on /root/tmp type none (rw,bind)
With a file system that supports Context-Dependent Path Names, you might have defined the
/bin
directory as a Context-Dependent Path Name that would resolve to one of the following paths, depending on the system architecture.
/usr/i386-bin /usr/x86_64-bin /usr/ppc64-bin
You can achieve this same functionality by creating an empty
/bin
directory. Then, using a script or an entry in the /etc/fstab
file, you can mount each of the individual architecture directories onto the /bin
directory with a mount -bind
command. For example, you can use the following command as a line in a script.
mount --bind /usr/i386-bin /bin
Alternately, you can use the following entry in the
/etc/fstab
file.
/usr/1386-bin /bin none bind 0 0
A bind mount can provide greater flexibility than a Context-Dependent Path Name, since you can use this feature to mount different directories according to any criteria you define (such as the value of
%fill
for the file system). Context-Dependent Path Names are more limited in what they can encompass. Note, however, that you will need to write your own script to mount according to a criteria such as the value of %fill
.
Warning
When you mount a file system with the
bind
option and the original file system was mounted rw
, the new file system will also be mounted rw
even if you use the ro
flag; the ro
flag is silently ignored. In this case, the new file system might be marked as ro
in the /proc/mounts
directory, which may be misleading.