4

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.

i.e...

$ find /usr/local/ /usr/local/one /usr/local/one/aaa /usr/local/one/bbb /usr/local/three /usr/local/three/fff /usr/local/two /usr/local/two/ccc /usr/local/two/ddd /usr/local/two/eee $ find /opt/oneTwoThree /usr/local/oneTwoThree /usr/local/oneTwoThree/aaa /usr/local/oneTwoThree/bbb /usr/local/oneTwoThree/fff /usr/local/oneTwoThree/ccc /usr/local/oneTwoThree/ddd /usr/local/oneTwoThree/eee 
6
  • 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? Commented Apr 7, 2011 at 15:51
  • Changes are user driven. The rarely edit the documents, but they can. Commented Apr 7, 2011 at 16:02
  • Editing the documents is fine: the issue for the linking method is if they add or delete documents. Commented Apr 7, 2011 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. Commented Apr 7, 2011 at 19:34
  • You should bounty this… I wonder if some sort of hardlinkling (like Apple's Time Mahine)… or ZFS could do it? Commented Jun 17, 2012 at 19:39

5 Answers 5

8

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

3

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.

2
  • Why do you say "if the directory contents are mostly static"? Commented Apr 7, 2011 at 15:59
  • 2
    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. Commented Apr 7, 2011 at 16:05
2

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

0

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.

0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.