I am exporting my /opt/target directory via NFS but I would like the nfs clients to be able to mount it as /target. i.e. I would like showmount -e to show /target not /opt/target. Can that be done?
What you want is how NFSv4 works. In NFSv4, all the directories exported are from a single pseudo-filesystem where the real directories are mounted with --bind. See the Ubuntu NFSv4 Howto for an example.
I'm pretty sure NFS does not allow for aliases. Symlinking is probably best, and it'll save you from moving the export as a whole to an illogical location (/target).
The original suggestion here was to symlink /opt/target to /target and then export /target. NFS supports this and I don't know of any good reasons not to use symlinks this way.
You would need to change the path on the server. I'm not sure if you can export via a symlink, otherwise you'd need to move the path physically on the server. Looking at the man page for exports, you might be able to use the "refer" option.
Since for me wzzrd's answer didn't work and Kamil Kisiel's answer refers to an external source I'll describe here how it exactly works for the op's use case:
What you want is how NFSv4 works. In NFSv4, all the directories exported are from a single pseudo-filesystem where the real directories are mounted with
--bind
. See the Ubuntu NFSv4 Howto for an example.I'm pretty sure NFS does not allow for aliases. Symlinking is probably best, and it'll save you from moving the export as a whole to an illogical location (/target).
The original suggestion here was to symlink /opt/target to /target and then export /target. NFS supports this and I don't know of any good reasons not to use symlinks this way.
You would need to change the path on the server. I'm not sure if you can export via a symlink, otherwise you'd need to move the path physically on the server. Looking at the man page for exports, you might be able to use the "refer" option.
Since for me wzzrd's answer didn't work and Kamil Kisiel's answer refers to an external source I'll describe here how it exactly works for the op's use case:
results in output: