使用取消共享创建挂载命名空间后,我无法覆盖挂载
$ unshare -rm
# mount -t overlay overlay -o lowerdir=/bin,upperdir=/overlay/upper/bin,workdir=/overlay/work/bin/ /overlay/merged/bin/
mount: /overlay/merged/bin: permission denied.
也尝试过
$ unshare -rmpf --mount-proc
# mount -t overlay overlay -o lowerdir=/bin,upperdir=/overlay/upper/bin,workdir=/overlay/work/bin/ /overlay/merged/bin/
mount: /overlay/merged/bin: permission denied.
这是 wsl 的限制吗?还是因为我不是真正的 root 用户?又或者我遗漏了什么?
绑定安装有效
# mount --bind /bin /overlay/merged/bin/
# grep bin /proc/self/mountinfo
127 126 0:19 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc binfmt_misc rw
137 106 8:16 /bin /overlay/merged/bin rw,relatime - ext4 /dev/sdb rw,discard,errors=remount-ro,data=ordered
我对 upper 和 work 有写权限,并且所有目录都在同一个文件系统上
find /overlay/{upper,work} -name bin -ls
38672 4 drwxr-xr-x 2 badger badger 4096 Nov 3 17:05 /home/badger/overlay/upper/bin
38631 4 drwxr-xr-x 3 badger badger 4096 Nov 4 23:08 /home/badger/overlay/work/bin