Sample Header Ad - 728x90

Why does OverlayFS allow unmounting the device that contains upperdir and workdir?

0 votes
1 answer
88 views
I have two hard drives, each with a single partition (/dev/sda1 and /dev/sdb1). The Linux root is on /dev/sda1. I run the following script.
mount /dev/sdb1 /mnt
mkdir /data /mnt/upper /mnt/work

mount -t overlay overlay -o lowerdir=/data,upperdir=/mnt/upper,workdir=/mnt/work /data

umount /mnt
I noticed two interesting behaviors here. 1. The overlay **overwrites its own** lowerdir (since /data is both the lowerdir and the mount target). 2. The overlay **continues working correctly** even after unmounting /dev/sdb1 (which holds upperdir and workdir). **Is this behavior reliable?** I couldn't find any documentation about this behavior in either the [mount(8)](https://man.archlinux.org/man/mount.8.en) man page or the official [OverlayFS](https://docs.kernel.org/filesystems/overlayfs.html) documentation. While eliminating extra mount points would be convenient, can this approach be considered truly reliable? **Here’s another example that also raises doubts.**
mount /dev/sdb1 /mnt
mkdir /mnt/dir
mount --bind /mnt/dir /dir
umount /mnt
Is the same mechanism at work here? Is this just as (un)reliable as the OverlayFS example?
Asked by user741127 (1 rep)
May 12, 2025, 04:10 PM
Last activity: May 12, 2025, 04:51 PM