This topic describes the common errors that occur when you mount Network File System (NFS) file systems on an Elastic Compute Service (ECS) instance that runs Alibaba Cloud Linux 2 or Alibaba Cloud Linux 3 and how to handle the errors.
The mount.nfs: command not found error message appears
Problem description
You replace the
<server_ip>parameter in the followingmount.nfscommand with the public IP address of an ECS instance and then run the command to mount an NFS file system on the instance:sudo mount.nfs <server_ip>:/directory /mntThe following error message appears:
-bash: mount.nfs: command not foundYou replace the
<server_ip>parameter in the followingmount -t nfscommand with the public IP address of an ECS instance and then run the command to mount an NFS file system on the instance:sudo mount -t nfs <server_ip>:/directory /mntThe following error message appears:
mount: /mnt: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
Cause
The nfs-utils package is missing or the required rpcbind components are not installed.
Solution
Run the following command to install the
nfs-utilspackage and therpcbindcomponents:sudo yum install -y nfs-utils rpcbindRun the following command to check whether the
nfs-utilspackage and therpcbindcomponents are installed:sudo yum list installed | grep nfs-utilsThe following command output indicates that the
nfs-utilspackage and therpcbindcomponents are installed.
The mount: /nfs/testdir: mount point does not exist error message appears
Problem description
You replace the <server_ip> parameter in the following command with the public IP address of an ECS instance and then run the command to mount an NFS file system to a mount point on the instance:
sudo mount -t nfs -o vers=3 <server_ip>:/export/fs/dir /nfs/testdirThe following error message appears:
mount: /nfs/testdir: mount point does not exist.Cause
The specified mount point does not exist on the ECS instance.
Solution
Create a mount point on the ECS instance. In this example, the /nfs/testdir mount point is created.
sudo mkdir -p /nfs/testdirThe "Operation not permitted" error message appears indicating insufficient permissions
This issue may occur only in NFSv4 or later file systems and does not occur in NFSv3 file systems.
Problem description
After you mount an NFS file system to a root-owned directory on an ECS instance, you cannot create files in the directory and receive the "Operation not permitted" error message even if you log on to the instance as root. In this example, the /nfs/testdir directory is used.
Run the following command to display the list of files and subdirectories in the
/nfs/testdirdirectory on the ECS instance:cd /nfs/testdir & ls -lhThe following command output is returned:
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+foundRun the following command to go to a subdirectory in the /nfs/testdir directory and create a file named testfile. In this example, the subdirectory named subdir is used.
cd subdir & touch testfileThe following error message appears:
touch: cannot touch 'testfile': Permission denied
Cause
The no_root_squash option is disabled for the NFS file system on the NFS server. Note that the owner and group of the subdir subdirectory are root, which refers to root users on the NFS server. If the no_root_squash option is disabled, root users on the NFS client are mapped to an anonymous user on the NFS server. As a result, the root users can manage only the files to which regular users have access in the NFS file system on the NFS server and cannot perform operations that require superuser privileges. If the no_root_squash option is enabled, root users on the NFS client are granted full permissions on the NFS file system on the NFS server.
Solution
Run the following command to open the
/etc/exportsfile:sudo vim /etc/exportsPress the
Ikey to enter Insert mode and append the following content to the file:/export/fs/vdc *(rw,no_subtree_check,no_root_squash)Press the
Esckey, enter:wq, and then press theEnterkey to save and close the file.Run the following command to update the export list of the NFS file system on the NFS server:
sudo exportfs -r