Is there a way to "refresh" an NFS mount?
Posted by lightnb11@reddit | linuxadmin | View on Reddit | 11 comments
If, on the NFS host you have /srv/nfs/example
exported, and /srv/nfs/example
is an empty directory, and a client has that share mounted, then, on the host, you mount a block device to /srv/nfs/example
, the client will still see an empty directory, instead of the mounted file system.
It seems the only way for the client to see the contents of the newly mounted volume is for the client to unmount the NFS share, then remount it.
Is there another way for a client to see a mount change that happened on the server and "refresh" itself, without having to unmount and remount on the client?
Cerulean-Knight@reddit
You should use automount, it's even integrated with systemd
yrro@reddit
I don't think automount/systemd alone will help here. The problem is that the client successfully mounted the wrong thing. automount + the
mp
export option together could help, though.yrro@reddit
There is a useful option in the exports file, I think it's called 'mp' which tells nfs-utils to not export the filesystem unless it is a mount point.
This on the server side and automount on the client side together will give you a robust way to ensure that the client either has the intended fs mounted or nothing mounted.
UsedToLikeThisStuff@reddit
This might work if your NFS server (nfsd) is in userspace instead of a kernel-based service. For example NFS Ganesha.
glenndrives@reddit
Use autofs?
EuphoricAbigail@reddit
Seconding this. Autofs will handle mounting the filesystem on demand so the user likely wouldn't notice changes to the mount on the server side.
planeturban@reddit
exportfs -ra on the server side maybe? It’ll restart the nfsd process.
smallcrampcamp@reddit
Won't this refresh all of the NFS connections though, not just the host they want?
ForceBlade@reddit
Yeah, you umount it (with -l if you need to) and remount it.
rautenkranzmt@reddit
No, because the open pointer for the nfs process on the server side is to the non-mounted directory.
On the upside, remounting isn't as hard as one would think. Can just run mount -o remount on the client (as root, almost certainly) to do the un/mount.
harrywwc@reddit
afaik, no.
the original nfs process will still be 'connected' to the old location (inode). the client will need to disconnect/reconnect to spawn a new connection to the new location.