Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I mount all my home directories and what ever else on my laptop when it is on my home network. I was wondering if there is a way to keep a local copy of the nfs mount when my laptop is off the network.

A bonus would be the ability to merge changed folders and files etc.

share|improve this question
Can you clarify if you really meant "when my laptop is on the network" or was that supposed to be off? – Caleb Jul 22 '11 at 10:54
up vote 6 down vote accepted

offline caches are one thing, but what you're asking for is more difficult. If a file is modified both on the server and on the client while the two machines are not connected, someone has to decide which version to keep, or to merge the two versions. Requiring this kind of user input when the two machines reconnect doesn't fit well into the filesystem model.

There are several NFS caching facilities, but most are designed for online caching, to speed up access. They require a communication between the server and the client when a file is modified on either side, so they're not suitable for offline scenarios. The same goes for AFS.

There are efforts to build a usable distributed filesystem supporting disconnected operation:

  • Coda is a distributed filesystem with a number of advanced features, in particular support for disconnected operation. It is a relatively old project, reasonably mature, and integrated in the Linux kernel. When a client is offline, its modifications are stored in a queue. When the client reconnects, these modifications are integrated if possible, and Coda comes with tools to assist merges when conflicts occur.
  • Tsumufs is a relatively new project. It adds disconnected operation on top of an existing distributed filesystem such as NFS. I don't think it's quite production-ready yet.

I'm not convinced that the filesystem is the right place to solve this problem. Conflict handling is difficult and requires user input.

For a low-tech solution, I recommend Unison, the bidirectional file synchronizer. Keep local copies of your files on both the server and the laptop. Immediately after connecting your laptop and immediately before disconnecting, run unison to synchronize the two sides. Unison will tell you if there's a conflict (and will operate silently if there isn't); as long as you always synchronize when connecting and disconnecting, there won't be a conflict.

A solution that provides more services, but does require some leearning, is to use some distributed version control software. Keep a repository on each machine, commit whenever you've changed a file, and don't forget to push/pull changes whenever possible.

share|improve this answer
Thanks for the suggestions. I was just about to start hacking some scripts together to get my idea working but I think I can make once of these work. Thanks again. – user174084 Jul 23 '11 at 3:42

If you want to keep the files and sync them just create a local copy and synchronize the NFS mount and your local copy using rsync.

share|improve this answer
I think the OP is after something a bit like windows offline files; or Mac's file synchronisation, where the mechanics of this are all performed for the user, rather than by the user. – jmtd Jul 22 '11 at 12:30
Such a script that does all the work can be created in minutes. Additionally something like Unison does cross-platform (bidirectional) synchronization but I would recommend using rsync any way. – muffel Jul 22 '11 at 12:34

Your Answer


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.