In case of unix/linux, is there a way to create union of two directories without copying or linking manually everything to a single directory?

link|improve this question

80% accept rate
feedback

4 Answers

up vote 14 down vote accepted

One option is to use unionfs

Unionfs: A Stackable Unification File System

This project builds a stackable unification file system, which can appear to merge the contents of several directories (branches), while keeping their physical content separate. Unionfs is useful for unified source tree management, merged contents of split CD-ROM, merged separate software package directories, data grids, and more. Unionfs allows any mix of read-only and read-write branches, as well as insertion and deletion of branches anywhere in the fan-out.

Or another similar option aufs.

link|improve this answer
1  
Your answer seems much better ! – Antoine Benkemoun Jun 5 '09 at 9:28
Having used unionfs to create a read-only filesystem with a read-write RAM FS on top of it, I can say that it's very easy to set up and works with little overhead. – andrewd18 Jun 5 '09 at 13:01
feedback

mhddfs is great for making a heap of drives that are transparently linked. It takes some /etc/fstab fiddling, but the solution works great for me

http://blog.mindlesstechie.net/2009/01/19/combine-your-partition-space-with-mhddfs/

link|improve this answer
feedback

Would copying the content of one directory in the other not cut it ? Or copy both of the contents into a single folder. The first options costs one command and the other two.

link|improve this answer
feedback

rsync -avz /path/1 /union/dir

rsync -avz /path/2 /union/dir

It'll work on local and remote directories.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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