How do I export a directory under a different name with the Network File System (NFS)?

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL) 3

Issue

  • You need client machines to mount a filesystem from your NFS server  under a specific name. The actual location of the filesystem on the  server is different from the location the clients are expecting to use.

Resolution

Assuming that you have a basic understanding of NFS; You can use symlinks to make a filesystem "appear" to clients, as having a different path on the server. All you need to do is create the symlink to the actual location of the files. Then add an export entry referencing the link.

For example:

You want the NFS filesystem server1:/very/long/path/name/on/server1 to be mounted by clients as "server1:/server1".

You would first create a symlink on server1 with the command:

# ln -s /very/long/path/name/on/server1 /server1

Next you would add an export entry in /etc/exports similar to:

/server1        *(ro,sync)

Lastly, reload your NFS exports file:

# exportfs -r

You should now be able to mount using this name from the client:

# mount server1:/server1 /mount/point/

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments