Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 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.

share|improve this answer
    
Rsync would traditionally make sense, but there's a chance that files would be modified at any given site. If I were mounting read-only, rsync would be a better choice. Unless you know of a two-way synchronization solution... –  ewwhite May 20 '11 at 19:26
    
One thing you can do with rsync is setup a cron job that checks timestamps on your files on each machine, and perhaps do it every 5min. As soon as an update is noticed push the files to nfs, and ad the same time perhaps create a trigger file that every other machines checks at a fixed period. As soon as they see this trigger they all run rsync to get most updated files from NFS. –  slashdot May 22 '11 at 3:41
    
I may try Unison as an approach to solving this. –  ewwhite May 23 '11 at 16:47
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.

share|improve this answer
    
But that would mount all of the root filesystem under /mnt. Hmm... –  ewwhite May 19 '11 at 21:24
    
So? What harm is it going to do? It just lets you synchronize the files you want. You can even put it in /private/root where /private is 700 root so no-one else can get at those files, not that it would do any harm if they could since they have exactly the same permissions. It seems basically like an exact answer to your question. Now if your question is how to recover once the NFS server goes away, that is entirely different, and probably involves force unmount. That will invalidate and thus break half of your processes forcing a reboot anyway. –  Seth Robertson May 20 '11 at 0:16
    
This was close, but I decided to just mount the directory I needed access to with the bind parameter to another location on the filesystem. –  ewwhite May 27 '11 at 13:04
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.