On Debian Stretch (running as root) this the current behaviour:
# Create base directory mkdir base touch base/example # Create merge, upper and work directories for 2 layers mkdir layer1 layer1.upper layer1.work mkdir layer2 layer2.upper layer2.work # Mount layer1 as the merged directory using layer1.upper as the true upper layer, # with base as a lower layer and layer1.work as the necessary work directory mount -t overlay overlay -o lowerdir=$(pwd)/base,upperdir=$(pwd)/layer1.upper,workdir=$(pwd)/layer1.work layer1 ls layer1 # should show example as expected ls layer1.upper # shows no file (this is expected behaviour, it should only show files written on layer1) rm layer1/example ls layer1 # should show no files ls layer1.upper # should show a special character device called "example", this is the "whiteout" file # unmount, and remount with layer2 being the new upper layer and using layer1.upper directory as the top level lower layer. umount layer1 mount -t overlay overlay -o lowerdir=$(pwd)/base:$(pwd)/layer1.upper,upperdir=$(pwd)/layer2.upper,workdir=$(pwd)/layer2.work layer2 ls layer2 # now shows example again as if it was never deleted
Is this a bug? Or is this a limitation/expected behaviour?
If expected, any suggestions on a quick and easy workaround?
FWIW it works as desired under auFS, so one workaround is to install aufs-dkms and continue to use auFS... I may do that regardless, but I would really like clarity on whether this is a bug or expected behaviour.
[update] I was doing it wrong, please see (the now corrected) answer!