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目录移动出挂载点,也是一样的。

相关推荐
菜择贰41 分钟前
在linux(wayland)中禁用键盘
linux·运维·chrome
oMcLin1 小时前
如何在 Manjaro Linux 上通过配置systemd服务管理,提升微服务架构的启动速度与资源效率
linux·微服务·架构
Kira Skyler1 小时前
bpftool -S 签名功能实现解析
linux
小杰帅气1 小时前
进程优先级与切换调度
linux·运维·服务器
方便面不加香菜1 小时前
Linux基本指令(1)
linux
济6172 小时前
linux(第十四期)--Uboot移植(1)-- Ubuntu20.04
linux
奋斗的阿狸_19862 小时前
键盘组合键监听与 xterm 唤醒程序
linux·运维·服务器
小张成长计划..2 小时前
【linux】2:linux权限的概念
linux·运维·服务器
马踏岛国赏樱花2 小时前
Windows与Ubuntu双系统,挂载D/E盘到Ubuntu下时只能读的问题
linux·windows·ubuntu
ben9518chen2 小时前
Linux操作系统基本使用
linux·运维·服务器