This topic describes how to edit configuration files in Linux to enable an automatic mount of a Network File System (NFS) file system at startup.

Prerequisites

The following operations are performed:
  1. Create a General-purpose NAS file system
  2. Create a mount target
  3. Install an NFS client

NAS Capacity and NAS Performance

You can edit the /etc/fstab configuration file in Linux to enable an automatic mount of an NFS file system at startup. You can also edit the /etc/rc.local configuration file to enable an automatic mount.

  1. Edit a configuration file to enable an automatic mount.
    • Recommended. Open the /etc/fstab configuration file and add the mount command.
      Note If you want to enable an automatic mount in CentOS 6.x, run the chkconfg netfs on command to enable the netfs service at startup.
      • To mount an NFSv4 file system, add the following command:
        file-system-id.region.nas.aliyuncs.com:/ /mnt nfs vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0
      • To mount an NFSv3 file system, add the following command:
        file-system-id.region.nas.aliyuncs.com:/ /mnt nfs vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0
    • Open the /etc/rc.local configuration file and add the mount command.
      Note Before you edit the /etc/rc.local configuration file, make sure that you have the execute permissions on the /etc/rc.local and /etc/rc.d/rc.local configuration files. For example, in CentOS 7.x, the execute permissions are not granted by default. Before you edit the /etc/rc.local configuration file, grant the execute permissions to the account that you use to log on to the server.
      • To mount an NFSv4 file system, add the following command:
        sudo mount -t nfs -o vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt
      • To mount an NFSv3 file system, add the following command:
        sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt
      The following table lists the parameters in the mount command.
      Parameter Description
      file-system-id.region.nas.aliyuncs.com:/ /mnt <Domain name of the mount target>:<Name of the shared directory> <Path of the mount directory>. Replace the domain name of the mount target, the name of the shared directory, and the path of the mount directory based on your business requirements.
      vers The protocol version of the file system. NFSv3 and NFSv4 are supported.
      _netdev Prevents the automatic mount before the network is connected.
      0 (the first value after noresvport) Specifies whether to back up the file system by running the dump command. Non-zero values indicate that a file system is backed up. For a NAS file system, set the value to 0.
      0 (the second value after noresvport) Specifies the order in which the fsck command checks file systems at startup. For a NAS file system, set the value to 0. It indicates that the fsck command does not run at startup.
      Mount options Multiple mount options are available when you mount a file system. For more information, see the following table.
  2. Run the reboot command to restart the ECS instance.