Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a large source code repository on a Linux NFS mount and I'd like to create a shadow copy of that repository such that only files that I write in this shadow repository are modified in my shadow repository. All other files remain symlinks or hardlinks to the master, original repository.

Can this be done with hardlinks on NFS?

I can envision a script where, much like in a version control system, I check out the files that I want to modify from the original, which causes the script to sever the link between master and shadow repositories, creating a copy of the master repository's file that I can then modify. However, I'm sure someone else has created a utility for this and I'm just not aware of the obscure Linux incantations needed to conjure up my solution.

share|improve this question
    
Don't know if you're still doing this, but these days I'd recommend using btrfs. It features copy-on-write cloning of directories which does exactly what you want here, without the hassle of keeping track of symlinks (and without any 3rd-party application being aware of the fact that these clones are "anything less" than the original files). Also with the added benefit that only differing blocks are stored when cloned files are changed. Other FSes (such as ZFS) also offer copy-on-write cloning, but not from any arbitrary directories or files. Btrfs is pretty cool that way :) –  DanielSmedegaardBuus Aug 24 '13 at 15:02

2 Answers 2

up vote 3 down vote accepted

The X11 window system included a set of utilities that included lndir (http://linux.die.net/man/1/lndir), which created a shadow a directory. It created a copy of the original directory such that:

  1. each directory in the copy was a real directory
  2. each regular file in the copy was a symbolic link to the original

When you want to modify a file, you have to:

  1. delete its symlink in the copy
  2. copy the original file to the directory tree copy
  3. and modify it

maybe more manual than what you want, but might be easier than setting up a new filesystem. In Ubuntu 12.04, this is part of the xutils-dev package.

share|improve this answer

A UnionFS-based setup could work for you. UnionFS lets you merge the NFS read-only with a writable, dynamically growing, loop device powered filesystem.

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.