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

相关推荐
海棠蚀omo14 小时前
Linux操作系统-进程(三)
linux·操作系统
半梦半醒*15 小时前
Prometheus监控物理服务器
linux·运维·服务器·centos·prometheus
mzhan01715 小时前
Linux: network: 拔插网线 interface down/up测试的痛点
linux·服务器·测试·破坏性测试
黑马金牌编程15 小时前
如何判断一台服务器是否负载过高?
linux·运维·性能调优·性能分析·故障排查
小锋学长生活大爆炸15 小时前
【知识】Linux将多条指令合并为一条执行
linux·运维·ubuntu
心灵宝贝19 小时前
CentOS 7 安装 bzip2-libs-1.0.6-13.el7.x86_64.rpm 的详细步骤
linux·运维·centos
mjx653019 小时前
windows查看端口使用情况,以及结束任务释放端口
linux
九皇叔叔20 小时前
Linux Shell 函数:从定义到实战,让脚本更高效
linux·运维·chrome·shell
璞致电子1 天前
fpga开发板ZYNQ 璞致 PZ7010/7020 邮票孔核心板简介-ZYNQ7000系列小系统学习板
linux·嵌入式硬件·学习·fpga开发·fpga·fpga开发板·xilinx开发板
第四维度41 天前
【全志V821_FoxPi】9-2 Linux IIC驱动MPU6050
linux·传感器·tina·mpu6050·v821