1

I am looking for a way to implement filesystem files/directories access layers.

So I could have this structure ex.:

/mountPointMerged/
/mountPointLayer1/a/b/c.txt
/mountPointLayer2/a/b/c.txt
/mountPointLayer3/a/b/c.txt

When accessing the file /mountPointMerged/a/b/c.txt, if the 2nd layer is mounted, it's file would be read/written only if the 3rd layer is NOT mounted, and if both 2nd and 3rd are umounted, the 1st would be accessed.

The point is, there must happen a merge. So, adding these files specifically in these layers:

/mountPointLayer1/a/b/d.txt
/mountPointLayer2/a/b/e.txt
/mountPointLayer3/a/b/f.txt

would provide this result:

ls /mountPointMerged/a/b/
c.txt
d.txt
e.txt
f.txt

Any new file created at /mountPointMerged/, would be written at the topmost mounted layer. But other layers could be accessed directly by accessing ex.: /mountPointLayer2/a/b/c.txt and not /mountPointMerged/.

Can it be done in some way?

6
  • Take a look at the overlay filesystem, it sounds like what you are looking for: kernel.org/doc/Documentation/filesystems/overlayfs.txt Commented Nov 29, 2016 at 21:32
  • @DepressedDaniel check AUFS at my answer, I found it to be highly user friendly :) Commented Dec 1, 2016 at 21:50
  • OverlayFS is similar to AUFS, except that OverlayFS is in the kernel tree and AUFS probably won't ever be. So OverlayFS is more portable across Linux distributions and installations than AUFS. Even Debian still installs a kernel without AUFS by default (though it is standard on Ubuntu). Commented Dec 1, 2016 at 22:55
  • @DepressedDaniel aufs is so small size, that wont be a problem at all! :) Anyway, I will keep it open to other answers, in case OverlayFS or some other proves to be more user friendly than AUFS. The last usage example I saw about overlayfs was unnecessarily complicated, what made me promptly giveup on it.. Commented Dec 1, 2016 at 23:05
  • 1
    @aquaris-power I don't see what size has to do with it. If the distribution kernel doesn't include aufs, there is no way to use it without building a custom kernel. It's a question of convenience mainly. Commented Dec 1, 2016 at 23:28

1 Answer 1

0

The flexibilest and most straight forward option I found was AUFS, ex.:

mount -t aufs -o "br=CustomFolderToWriteAt:CustomTopOverriderFolder:CustomInBetweenOverriderFolders:CustomLowestPriorityFolder" none CustomMergedMountPointFolder

CustomFolderToWriteAt will contain all modifications that would be written at CustomMergedMountPointFolder, even if you touch a file, it will create a full copy of such, there.

CustomInBetweenOverriderFolders, there can have many here separated by ":".

Changes to the other custom folders instantly apply at the merged CustomMergedMountPointFolder.

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.