Server Fault is a question and answer site for system and network administrators. 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 have three directories on a linux (Red Hat) system. Say /usr/local/one, /usr/local/two, and /usr/local/three. I would like to have a mechanism which behaves like a directory which combines the contents of one, two, and three into /opt/oneTwoThree without physically moving their files contents.


$ find /usr/local/

$ find /opt/oneTwoThree
share|improve this question
Are the contents going to change - i.e. do you want them combined dynamically or will a one-off hard-link or symlink combine do? – Rup Apr 7 '11 at 15:51
Changes are user driven. The rarely edit the documents, but they can. – dacracot Apr 7 '11 at 16:02
Editing the documents is fine: the issue for the linking method is if they add or delete documents. – Rup Apr 7 '11 at 16:04
This sounds a bit counter intuitive to me. Why would you want to organize folders, then discard such organization? Is it for searching purposes? If it is, consider using instead search indexers such as Beagle and Tracker. – Ekevoo Apr 7 '11 at 19:34
You should bounty this… I wonder if some sort of hardlinkling (like Apple's Time Mahine)… or ZFS could do it? – mralexgray Jun 17 '12 at 19:39

You can use UnionFS that seems to be actively developed or in case of the directories being separated hard drives, MHDDFS, but I see less references to that last one.

EDIT: There's an wikipedia article with more palatable info on UnionFS

share|improve this answer

If the directory contents are mostly static, you might achieve that with symbolic links, i.e. symlinking every file present in each of the three directories to a fourth one.

share|improve this answer
Why do you say "if the directory contents are mostly static"? – dacracot Apr 7 '11 at 15:59
Because you'd need to add or remove symlinks from the combined directory if the user adds or removes files from the source directories - it's a manual sync-up step. – Rup Apr 7 '11 at 16:05

For anyone else that stumbles across this old question, Inotify could be used to monitor the directories and automatically create the links.

share|improve this answer

You could symlink the contents of /usr/local/{0ne,two,three} into /usr/local/four, but that's not very elegant. If alot of new files or directories are created in any of the original directories, you'd have to have some way (maybe via inotifyd?) to update the symlinks. It would work but it feels kludgy to me, and I hate to even suggest it.

share|improve this answer

Some (quite a few) years ago I had a slightly similar problem (wanted to install open source stuff into separate dirs - similar to the /opt/* scheme in use today - but not have to keep updating $PATH)

The solution for me was to use CMU depot to automate the creation and maintenance of a /usr/local/* hierarchy that encompassed all of the /opt-like stuff using links and/or symlinks.

share|improve this answer

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.