I am trying to mount an overlayfs on /tmp from within a separate user & mount namespace. This works well unless /tmp already has a child mount in the original namespace, in which case this reliably fails (number of $s distinguishes user/mount namespaces):
# Number of $'s distinguishes user/mount namespaces
$ mkdir -p /home/user/empty
$ mkdir -p /home/user/overlay/{upper,work}
$ unshare -rm
$$ mount --rbind /home/user/empty /tmp/mount
$$ unshare -rm
$$$ mount -t overlay overlay -o lowerdir=/tmp,upperdir=/home/user/overlay/upper,workdir=/home/user/overlay/work /tmp
mount: /tmp: wrong fs type, bad option, bad superblock on overlay, missing codepage or helper program, or other error.
$$$ journalctl -n 10
... kernel: overlayfs: failed to clone lowerpath
Is there any way to get an overlayfs in place on /tmp in this situation? I do not care about the contents of the child mounts, but e.g. bind mounting empty directories on top of the mount points doesn't unblock the overlayfs mount.