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
bindoption of the
bindoption of the
mountcommand 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.
After executing this command, the contents of the
olddirdirectory are available at two locations:
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/tmpwill be identical to the contents of the previously mounted
cd ~root[root@menscryfa ~]#
mkdir ./tmp[root@menscryfa ~]#
mount --bind /var/log /tmp
Alternately, you can use an entry in the
/etc/fstabfile to achieve the same results at mount time. The following
/etc/fstabentry will result in the contents of
/root/tmpbeing identical to the contents of the
/var/log /root/tmp none bind 0 0
After you have mounted the file system, you can use the
mountcommand to see that the file system has been mounted, as in the following example.
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
/bindirectory 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
/bindirectory. Then, using a script or an entry in the
/etc/fstabfile, you can mount each of the individual architecture directories onto the
/bindirectory with a
mount -bindcommand. 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
/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
%fillfor 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
When you mount a file system with the
bindoption and the original file system was mounted
rw, the new file system will also be mounted
rweven if you use the
roflag is silently ignored. In this case, the new file system might be marked as
/proc/mountsdirectory, which may be misleading.