One*_*kid 5 linux permissions nfs tmpfs overlayfs
概要
我正在从本地计算机提供 NFS 共享,虽然挂载和访问共享按预期工作,但当我尝试将 NFS 引用为 overlayfs 中的较低目录时,需要子目录的 exec/read/write 权限的操作会失败,并显示不支持操作
设置
这是我在本地设置安装的方法
sudo mkdir -p tmpfs_dir
sudo mount -t tmpfs -o size=4096m tmpfs tmpfs_dir
mkdir -p tmpfs_dir/{lower,upper,work}
sudo mount -t nfs -o ro,nolock,noacl,vers=3,proto=tcp 127.0.0.1:/nfsshare tmpfs_dir/lower
mkdir -p overlay_dir
sudo mount -t overlay -o lowerdir=tmpfs_dir/lower,upperdir=tmpfs_dir/upper,workdir=tmpfs_dir/work none overlay_dir
Run Code Online (Sandbox Code Playgroud)
在overlayfs的根上调用ls -好
ls -lah overlay_dir
total 108K
drwxr-xr-x 1 myuser myuser 40 Feb 12 00:31 .
drwxr-xr-x 7 myuser myuser 4.0K Feb 11 17:19 ..
drwxr-xr-x 2 root root 4.0K Aug 20 16:07 bin
drwxr-xr-x 4 root root 4.0K Aug 16 14:36 boot
drwxr-xr-x 20 root root 4.0K Aug 20 15:57 dev
drwxr-xr-x 98 root root 4.0K Sep 10 18:13 etc
drwxr-xr-x 3 root root 4.0K Aug 7 2019 home
...
Run Code Online (Sandbox Code Playgroud)
在overlayfs的子目录上调用ls -中断
ls -lah overlay_dir/bin
ls: cannot open directory 'overlay_dir/bin': Operation not supported
Run Code Online (Sandbox Code Playgroud)
在 NFS 的根目录上调用 ls -好
ls -lah tmpfs_dir/lower
total 108K
drwxr-xr-x 1 myuser myuser 40 Feb 12 00:31 .
drwxr-xr-x 7 myuser myuser 4.0K Feb 11 17:19 ..
drwxr-xr-x 2 root root 4.0K Aug 20 16:07 bin
drwxr-xr-x 4 root root 4.0K Aug 16 14:36 boot
drwxr-xr-x 20 root root 4.0K Aug 20 15:57 dev
drwxr-xr-x 98 root root 4.0K Sep 10 18:13 etc
drwxr-xr-x 3 root root 4.0K Aug 7 2019 home
...
Run Code Online (Sandbox Code Playgroud)
在 NFS 的子目录上调用 ls -好
ls -lah tmpfs_dir/lower/bin
total 16M
drwxr-xr-x 2 root root 4.0K Aug 20 16:07 .
drwxr-xr-x 26 root root 4.0K Feb 7 14:57 ..
-rwxr-xr-x 1 root root 1.1M Jun 6 2019 bash
-rwxr-xr-x 1 root root 700K Mar 12 2018 btrfs
lrwxrwxrwx 1 root root 5 Mar 12 2018 btrfsck -> btrfs
-rwxr-xr-x 1 root root 368K Mar 12 2018 btrfs-debug-tree
-rwxr-xr-x 1 root root 364K Mar 12 2018 btrfs-find-root
-rwxr-xr-x 1 root root 388K Mar 12 2018 btrfs-image
...
Run Code Online (Sandbox Code Playgroud)
从overlayfs的子目录调用可执行文件 -中断
overlay_dir/bin/bash
bash: overlay_dir/bin/bash: Operation not supported
Run Code Online (Sandbox Code Playgroud)
使用overlayfs 访问根目录下的任何内容似乎都会显示“操作不支持”错误。然而,我发现,递归调用修复了覆盖共享中的文件,但是(i)这似乎是不必要的修改安装后权限的黑客行为,并且(ii)检测文件所有者失败有点麻烦所以(例如盲目地在每个子目录上运行)将在所有者不同的实例上抛出错误chown
sudo chown
sudo chown -R root bin
ls -lah bin/bash
-rwxr-xr-x 1 root root 1.1M Jun 6 2019 bin/bash
overlay_dir$ bin/bash -c "echo 'why does it work now?'"
why does it work now?
Run Code Online (Sandbox Code Playgroud)
太长了;博士
如何从overlayfs中正确挂载NFS,这样我就不必在挂载后修改权限?
眼镜
Ubuntu 18.04
5.3.0-28-generic
libmount 2.31.1
进一步的考虑
归档时间: |
|
查看次数: |
3199 次 |
最近记录: |