本文将为您介绍在Alibaba Cloud Linux 2和Alibaba Cloud Linux 3系统中挂载NFS文件系统时常见的错误原因及其解决方案。
mount.nfs: command not found
问题现象
通过
mount.nfs
方式挂载NFS文件系统。<server_ip>
需替换为对应实例的公网IP地址。sudo mount.nfs <server_ip>:/directory /mnt
报错信息如下:
-bash: mount.nfs: command not found
通过
mount -t nfs
方式挂载NFS文件系统。<server_ip>
需替换为对应实例的公网IP地址。sudo mount -t nfs <server_ip>:/directory /mnt
报错信息如下:
mount: /mnt: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
问题原因
系统缺少nfs-utils
包或者没有安装相关的rpcbind
组件。
解决方案
执行以下命令,安装
nfs-utils
包和rpcbind
组件。sudo yum install -y nfs-utils rpcbind
查看
nfs-utils
包和rpcbind
组件安装是否成功。sudo yum list installed | grep nfs-utils
结果如下图所示,表示组件安装成功。
mount: /nfs/testdir: mount point does not exist
问题现象
执行以下命令,挂载NFS。
<server_ip>
需替换为对应实例的公网IP地址
sudo mount -t nfs -o vers=3 <server_ip>:/export/fs/dir /nfs/testdir
报错信息为:
mount: /nfs/testdir: mount point does not exist.
问题原因
本地挂载点不存在。
解决方案
创建本地挂载点,本文以创建/nfs/testdir
挂载点为例。
sudo mkdir -p /nfs/testdir
挂载后读写文件提示权限不足“Operation not permitted”
该问题仅在NFSv4
及以上版本可能发生,NFSv3
不会出现类似问题。
问题现象
挂载NFS文件系统后,某子文件夹的目录所属用户为root
。即使当前本地用户为root
,依然无法在目录下新建文件,提示“Operation not permitted”。以通过NFS挂载的远程文件夹到本地文件夹/nfs/testdir为例。
执行以下命令,查看
/nfs/testdir
目录中的信息。cd /nfs/testdir && ls -lh
返回信息如下所示:
total 20K drwxr-xr-x 2 root root 4.0K Sep 5 13:08 subdir drwx------ 2 root root 16K Sep 5 13:07 lost+found
执行以下命令,进入子目录并创建文件。
cd subdir && touch testfile
报错信息如下所示:
touch: cannot touch 'testfile': Permission denied
问题原因
远程的服务器端对应的文件夹未开启“no_root_squash”
。注意到,subdir
的所属用户和用户组都为root
,但这里指代的是服务器端的root
用户。在未开启这一配置项时,客户端的root
用户会被映射为服务器端的一个匿名用户,因此在NFS共享目录上,root
用户只能操作普通用户拥有权限的文件,无法进行一些需要超级权限的操作。配置了no_root_squash
后,客户端的root
用户就拥有了该共享目录的全部权限。
解决方案
执行以下命令,打开
/etc/exports
文件。sudo vim /etc/exports
按
i
键进入编辑模式,添加以下内容。/export/fs/vdc *(rw,no_subtree_check,no_root_squash)
按
Esc
键,输入:wq
后按Enter
键,保存文件并退出。执行以下命令,在服务器端更新共享文件的配置。
sudo exportfs -r
- 本页导读 (1)
- mount.nfs: command not found
- 问题现象
- 问题原因
- 解决方案
- mount: /nfs/testdir: mount point does not exist
- 问题现象
- 问题原因
- 解决方案
- 挂载后读写文件提示权限不足“Operation not permitted”
- 问题现象
- 问题原因
- 解决方案