Access files located on the underlying filesystem of an NFS mountpoint
Perhaps this is an odd request, but it's the opposite of the question detailed at:
Is it possible to view the contents of an underlying NFS mount without unmounting the NFS content?
I have an arrangement where Linux servers at multiple remote sites mount an NFS share from a central server (all CentOS 5.x). Think: /opt/software
or something similar.
If all is well, the client systems mount the NFS export from the main server and run without incident. The data contained within the share does not change frequently (perhaps weekly).
I'm concerned about the situation where there's a loss of connectivity to the main NFS server (NFS server outage, fiber-cut, etc.). Due to the fact the the shared data does not change often, I'd like for these systems to be able to run standalone if they lose the NFS mount.
Say the mount goes away, I'd like to use the local files sitting in /opt/software
underneath the NFS mount at the same location. Additionally, I'd keep a daily sync of those files.
The NFS mount is read/write because changes to the mounted volume need to be possible from any of the client sites.
Is this possible? How do I access (or overwrite) the files in the underlying directory? Would there potentially be timeout issues? Are there any mount options/tips that could help with this?
Solution 1:
mount -o bind / /mnt
When you look at /mnt/opt/software you will find the files (if any) which are underneath the mount in /opt/software.
Solution 2:
This is possible by using the mount --bind
option.
Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is
mount --bind olddir newdir
After this call the same contents is accessible in two places.
So I was able to mount --bind /opt/software /foo
And then apply the NFS mount over /opt/software
, retaining the ability to see the underlying files at /foo
.
Solution 3:
What you might need, since the files are relatively static, is rsync. Unless multiple remote clients have ability to change files. If data is essentially read-only, why not just rsync a couple of times a day via some cron-like job, on each machine. Again, I may be missing the point, but if data on NFS is basically read-only-like, this might do it.