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:


Then I expect to see in the target:


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".

  • you should see all 3 files. works for me. – meuh May 24 at 14:00
  • @meuh: that's odd, and so I retested again myself, and what I seem to observe is that directories are correctly merged if they exist at the time of issuing the mount command, but if they are created after the mounting, then they are not. – jl6 May 24 at 14:50
  • 2
    You need to read further in the doc: Changes to the underlying filesystems while part of a mounted overlay filesystem are not allowed. – meuh May 24 at 15:16
  • @meuh: Thanks, that seems to be the explanation. I've been happily changing the underlying filesystems and seeing expected results when adding files, so I suppose the undefined behaviour just happened to correspond to my expectations and I did not anticipate the undefined behaviour being different for directories! – jl6 May 24 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.