The tar command copies the entire directory tree from the current directory to /usr/marker (see the manpage for tar(1) for a more detailed explanation). On the server, the redirection imposed by the symbolic link is invisible to users. However, an NFS client that mounts /tools/marker and tries to use it will be in for a surprise when the client tries to find the fonts subdirectory. The client looks at /tools/marker/fonts, realizes that it's a symbolic link, and asks the NFS server to read the link. The NFS server returns the link's target -- /usr/marker/fonts -- and the client tries to open this directory instead. On the client, however, this directory does not exist. It was created for convenience on the server, but breaks the NFS clients that use it. To fix this problem, you must create the same symbolic link on all of the clients, and ensure that the clients can locate the target of the link. Think of symbolic links as you would files on an NFS server. The server does not interpret the contents of files, nor does it do anything with the contents of a link except pass it back to the user process that issued the readlink RPC. Symbolic links are treated as if they existed on the local host, and they are interpreted relative to the client's filesystem hierarchy.# mkdir /usr/marker # cd /tools/marker # tar cf - fonts | ( cd /usr/marker; tar xbBfp 20 - ) # rm -rf fonts # ln -s /usr/marker/fonts fonts
If you mount just /usr/local/bin from this server, you will not be able to use any of the executables in it unless you have them in the directory /usr/local/bin.mips. Using symbolic links to reduce the number of directories in a pathname is beneficial only if users are not tempted to cd from one link to another:% cd /usr/local/bin % ls -l total 1 lrwxrwxrwx 1 root bin 16 Jun 8 1990 a2ps -> ../bin.mips/a2ps lrwxrwxrwx 1 root bin 12 Jun 8 1990 mp -> ../bin.mips/mp
The unsuspecting user tries to use the path-compressed names, but finds that relative pathnames aren't relative to the link directory:# ln -s /minnow/fred /u/fred # ln -s /alewife/lucy /u/lucy
A user may be bewildered by this behavior. According to the /u directory, fred and lucy are subdirectories of a common parent. In reality, they aren't. The symbolic links hide the real locations of the fred and lucy directories, which do not have a common parent. Using symbolic links to shorten pathnames in this fashion is not always the most efficient solution to the problem; NFS mounts can often be used to produce the same filesystem naming conventions.% cd /u/fred % cd ../lucy ../lucy: No such file or directory
as this sequence does:# mkdir -p /users/hal # ln -s /users/hal /usr/hal # mount bitatron:/export/home/hal /usr/hal
The filesystem is mounted on the directory /users/hal and the symbolic link /usr/hal has the mount point as its target. You should make sure that the directory pointed to by the link is on a filesystem that is mounted read/write and that performing the mount will not obscure any required filesystem underneath the symbolic link target. Exporting a symbolic link from a server follows similar rules. The filesystem or subtree of a filesystem that is really exported is the one pointed to by the symbolic link. If the parent of the link's target has already been exported, or a subtree of it is exported, the attempt to export the link fails. More interesting than exporting a symbolic link is mounting one from the server. Mounting a link from a server is not the same thing as mounting a filesystem containing a symbolic link. The latter means that there is a symbolic link somewhere in the filesystem mounted using NFS. The former case implies that the server pathname used to locate the remote filesystem is a link and directs the mount somewhere else. The client mounts the directory pointed to by the link. As shown in Figure 6-1, if /usr/man is a symbolic link to /usr/share/man, then this mount command:# mkdir -p /users/hal # mount bitatron:/export/home/hal /users/hal # ln -s /users/hal /usr/hal
does the same thing as this mount command:# mount bitatron:/usr/share/man /mnt
# mount bitatron:/usr/man /mnt
6.3. Mounting filesystems | 6.5. Replication |
Copyright © 2002 O'Reilly & Associates. All rights reserved.