I'm using overlayfs to merge three directories together as follows:
mount -t overlay overlay -o lowerdir=/dir1:/dir2:/dir3 /targetdir
This works partially according to my expectations. Some files from the lower directories are visible in the target directory, but directories are not merged. For example, if I have the following files:
/dir1/subdir/file1 /dir2/subdir/file2 /dir3/subdir/file3
Then I expect to see in the target:
/targetdir/subdir/file1 /targetdir/subdir/file2 /targetdir/subdir/file3
But what I actually see is:
It looks like the directories are not merging, but instead the rightmost entry in the
lowerdir list is taking precedence over the other entries.
This is what I believe to be the relevant part of the documentation:
Multiple lower layers can now be given using the the colon (“:”) as a separator character between the directory names. For example:
mount -t overlay overlay -olowerdir=/lower1:/lower2:/lower3 /merged
As the example shows, “upperdir=” and “workdir=” may be omitted. In that case the overlay will be read-only.
The specified lower directories will be stacked beginning from the rightmost one and going left. In the above example lower1 will be the top, lower2 the middle and lower3 the bottom layer.
I am now wondering if I should be interpreting the word "stacked" in the above in a different way, as I had assumed it meant "merged".