Mount an NFS file system on Linux

更新时间:
复制 MD 格式

Mount a Network File System (NFS) file system on your Edge Node Service (ENS) instances so that multiple ENS instances can share the same file system.

Prerequisites

Before you begin, ensure that you have:

  • A Linux ENS instance running on the edge node where the NAS file system was created

  • A NAS file system with its mount target URL available

  • The NAS file system and the ENS instance in the same virtual private cloud (VPC)

Mount an NFS file system

Step 1: Connect to the ENS instance

Log on to your Linux ENS instance.

Step 2: Install the NFS client

Install the NFS client before mounting. You only need to install it once per ENS instance.

Operating systemInstallation command
CentOSsudo yum install nfs-utils
Ubuntusudo apt-get update
Debiansudo apt-get install nfs-common

Step 3: Mount the file system

Get the mount commands from the details page of your target file system. For details, see View a mount target.

Choose a protocol:

  • NFSv3 — recommended for optimal performance

  • NFSv4 — use when multiple ENS instances need to modify the same file simultaneously (supports file locks and range locks)

To mount with NFSv3:

sudo mount -t nfs -o \
vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport \
100.64.XXX.XXX:/UID/source_path /target_path
By default, the UID is included in mount target addresses for NFSv3 as part of the file system directory path.

To mount with NFSv4:

sudo mount -t nfs -o \
vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport \
100.64.XXX.XXX:/source_path /target_path

Mount parameters

Replace the placeholders in the commands with your actual values:

ParameterDescription
100.64.XXX.XXXMount target address. View it on the NAS page.
/source_pathA subdirectory in the NAS file system (for example, /share). Cannot be the root directory.
/target_pathThe local mount point on the ENS instance (for example, /mnt). Must already exist.
versNFS protocol version: 3 for NFSv3, 4 for NFSv4.
minorversionMinor version for NFSv4. NAS supports NFSv4.0, so set this to 0.
rsizeSize of data blocks the client reads from the file system. Set to 1048576 to prevent performance degradation. Do not change this value.
wsizeSize of data blocks the client writes to the file system. Set to 1048576 to prevent performance degradation. Do not change this value.
hardRetry behavior when NAS is unavailable. Without hard, the client may return errors immediately without retrying, which can cause data loss or inconsistency. Keep this enabled.
timeoTime the NFS client waits before retrying a request, in deciseconds (tenths of a second). Default: 600 (60 seconds). If you must change this value, use 150 or higher (15 seconds minimum) to avoid performance degradation.
retransNumber of retry attempts before the client reports an error. Recommended: 2.
noresvportUses a new TCP port when the network recovers from a failure, preserving connectivity between the file system and the instance. Keep this enabled.
Important

Do not use the soft mount option — it can cause data inconsistency. Do not modify rsize, wsize, or attribute caching settings, as these changes reduce performance.

Multi-NIC configuration

If the ENS instance has only one internal NIC (primary NIC), the default route for NAS already points to it — no extra configuration is needed.

If the instance has multiple NICs (a public NIC and an internal NIC), the internal NIC cannot access NAS by default. Add a static route manually before mounting:

ip route add 100.64.xxx.xxx dev ethX

Replace 100.64.xxx.xxx with the NAS mount target address and ethX with your internal NIC name.

Step 4: Verify the mount

After the NFS file system is mounted, run the df -h command to view the capacity of the NFS file system.