Linux:nfs网盘共享盘无法创建文件,提示无权限

一、原因

主盘/u01/apps/hesp/images 是属于root用户,共享盘查看时的用户是主盘的root用户,因为没有赋权,所以共享盘创建文件时提示无权限;

主盘
[root@scyf-web images]# cat /etc/passwd
......
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
......
[root@scyf-coll images]# ls -lrt
total 488
drwxr-xr-x. 2 root root      6 Nov 23  2022 bak
-rw-r--r--. 1 root root 484474 Nov 23  2022 appMarket.zip
drwxr-xr-x. 6 root root     78 Dec  1  2022 appMarket
drwxr-xr-x. 4 root root    103 Mar 22  2023 material
drwxr-xr-x. 3 root root     19 Aug 29 09:50 docxToPdf
-rw-r--r--. 1 root root  11316 Nov 16 17:04 移动终端编码清单.xlsx

共享盘
[root@scyf-coll images]# ls -lrt
total 488
drwxr-xr-x. 2 root root      6 Nov 23  2022 bak
-rw-r--r--. 1 root root 484474 Nov 23  2022 appMarket.zip
drwxr-xr-x. 6 root root     78 Dec  1  2022 appMarket
drwxr-xr-x. 4 root root    103 Mar 22  2023 material
drwxr-xr-x. 3 root root     19 Aug 29 09:50 docxToPdf
-rw-r--r--. 1 root root  11316 Nov 16 17:04 移动终端编码清单.xlsx
[root@scyf-coll images]# touch 123.sh
touch: cannot touch ‘123.sh’: Permission denied

二、解决办法

1. 将主盘的文件所属权限修改为用户nfsnobody;

主盘
[root@scyf-web images]# chown -R nfsnobody:nfsnobody images/
[root@scyf-coll images]# ll
total 488
drwxr-xr-x. 6 nfsnobody nfsnobody     78 Dec  1  2022 appMarket
-rw-r--r--. 1 nfsnobody nfsnobody 484474 Nov 23  2022 appMarket.zip
drwxr-xr-x. 2 nfsnobody nfsnobody      6 Nov 23  2022 bak
drwxr-xr-x. 3 nfsnobody nfsnobody     19 Aug 29 09:50 docxToPdf
drwxr-xr-x. 4 nfsnobody nfsnobody    103 Mar 22  2023 material
-rw-r--r--. 1 nfsnobody nfsnobody  11316 Nov 16 17:04 移动终端编码清单.xlsx

共享盘
[root@scyf-coll images]# ll
total 488
drwxr-xr-x. 6 nfsnobody nfsnobody     78 Dec  1  2022 appMarket
-rw-r--r--. 1 nfsnobody nfsnobody 484474 Nov 23  2022 appMarket.zip
drwxr-xr-x. 2 nfsnobody nfsnobody      6 Nov 23  2022 bak
drwxr-xr-x. 3 nfsnobody nfsnobody     19 Aug 29 09:50 docxToPdf
drwxr-xr-x. 4 nfsnobody nfsnobody    103 Mar 22  2023 material
-rw-r--r--. 1 nfsnobody nfsnobody  11316 Nov 16 17:04 移动终端编码清单.xlsx
2.配置共享盘root用户可修改权限
#主盘 配置NFS配置文件
[root@scyf-coll images]# vim /etc/exports
/data/apps/hesp/images/ 10.107.8.0/24(rw,sync,no_root_squash)
#使配置立即生效
[root@scyf-coll images]# exportfs -r
参数说明
ro只读访问
rw读写访问
sync所有数据在请求时写入共享
asyncnfs 在写入数据前可以响应请求
securenfs 通过 1024 以下的安全 TCP/IP 端口发送
insecurenfs 通过 1024 以上的端口发送
wdelay如果多个用户要写入 nfs 目录,则归组写入(默认)
no_wdelay如果多个用户要写入 nfs 目录,则立即写入,当使用 async 时,无需此设置
hide在 nfs 共享目录中不共享其子目录
no_hide共享 nfs 目录的子目录
subtree_check如果共享 /usr/bin 之类的子目录时,强制 nfs 检查父目录的权限(默认)
no_subtree_check不检查父目录权限
all_squash共享文件的 UID 和 GID 映射匿名用户 anonymous,适合公用目录
no_all_squash保留共享文件的 UID 和 GID(默认)
root_squashroot 用户的所有请求映射成如 anonymous 用户一样的权限(默认)
no_root_squashroot 用户具有共享根目录的完全管理访问权限
anonuid=xxx指定 nfs 服务器 /etc/passwd 文件中匿名用户的 UID
anongid=xxx指定 nfs 服务器 /etc/passwd 文件中匿名用户的 GID

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值