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

相关推荐
Gaoithe4 小时前
ubuntu 端口复用
linux·运维·ubuntu
德先生&赛先生4 小时前
Linux编程:1、文件编程
linux
程序猿小D5 小时前
第16节 Node.js 文件系统
linux·服务器·前端·node.js·编辑器·vim
多多*6 小时前
微服务网关SpringCloudGateway+SaToken鉴权
linux·开发语言·redis·python·sql·log4j·bootstrap
IT界小黑的对象7 小时前
virtualBox部署ubuntu22.04虚拟机 NAT+host only 宿主机ping不通虚拟机
linux·运维·服务器
SilentCodeY7 小时前
Ubuntu 系统通过防火墙管控 Docker 容器
linux·安全·ubuntu·系统防火墙
weixin_527550408 小时前
Linux 环境下高效视频切帧的实用指南
linux·运维·音视频
keson要进步8 小时前
CICD实战(二)-----gitlab的安装与配置
linux·运维·gitlab
藥瓿亭8 小时前
K8S认证|CKS题库+答案| 4. RBAC - RoleBinding
linux·运维·服务器·云原生·容器·kubernetes·cks
吐泡泡_8 小时前
Linux(线程控制)
linux