nfs 的 subtree_check 属性

subtree_check 是说在用一个 file handle 时,要检查它的挂载点变化,且到挂载点之间的目录均有访问权限。举例说明:

  • 服务端导出两个目录 /export_a /export_b
  • 客户端在挂载了 /export_a 目录,当前在 /export_a/a 目录下
  • 服务端执行 mv /export_a/a /export_b/,将export_a下的 a 目录转至 export_b 导出点下
  • 客户端在 a 目录下创建文件 b

这时 subtree_check 与 no_subtree_check 就会起作用:

  • 服务端如果在/etc/export 下在 /export_a 目录配置了 subtree_check,则在检查从a目录向上的挂载点时发现挂载点变化,创建文件失败
  • 服务端如果在/etc/export 下在 /export_a 目录配置了 no_subtree_check,则不检查a目录的导出点变化,可以成功创建文件
bash 复制代码
# /root/mnt/x/ 的权限是只读
[root@localhost nfs]# ll
总用量 4
dr--r--r--. 4 root root 4096  6月  5 10:03 x

--------------------------------------------------------
[root@localhost ww]# cat /etc/exports
/root/mnt *(rw,sync,subtree_check,no_root_squash)  # check
/root/mnt/x *(rw,sync,subtree_check,no_root_squash)

[test@localhost nfs]$ cd ww
# [root@localhost tracing]# mv /root/mnt/ww /root/mnt/x/  # 移至其它只读挂载点
[test@localhost ww]$ mkdir aa
mkdir: 无法创建目录 "aa": Stale file handle    # 失败

--------------------------------------------------------
[root@localhost ww]# cat /etc/exports
/root/mnt *(rw,sync,no_subtree_check,no_root_squash)  # no check
/root/mnt/x *(rw,sync,subtree_check,no_root_squash)

[test@localhost nfs]$ cd ww
# [root@localhost tracing]# mv /root/mnt/ww /root/mnt/x/  # 移至其它只读挂载点
[test@localhost ww]$ mkdir aa   
[test@localhost ww]$             # 成功

除此之外,如果a目录移动出挂载点,也是一样的。

相关推荐
chlk1231 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑1 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件1 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI2 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行3 天前
Linux和window共享文件夹
linux
木心月转码ing3 天前
WSL+Cpp开发环境配置
linux
崔小汤呀4 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端
何中应4 天前
vi编辑器使用
linux·后端·操作系统