All Products
Search
Document Center

Cloud Storage Gateway:Access an NFS share

Last Updated:Jan 31, 2024

This topic describes how to access a Network File System (NFS) share from a Linux Elastic Compute Service (ECS) instance.

Prerequisites

An NFS share is created. For more information, see Create a share.

Manually mount an NFS share

  1. Log on to the ECS console.

  2. Connect to your Linux ECS instance. For more information, see Connect to an instance.

  3. On the ECS instance, run the following command to mount an NFS share to a local directory of the client:

    • IPv4:

      mount.nfs 192.168.0.0:/shares local-directory
    • IPv6:

      mount.nfs [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares local-directory
    • If you use the NFS version 3 protocol, perform the following steps to mount the share:

      1. Run the following command to query the mount target. In this example, the mount target is 192.168.0.0:/shares.

        showmount -e <gateway IP address>
      2. Run the following command to mount the share:

        mount -t nfs -o vers=3,proto=tcp,nolock 192.168.0.0:/shares local-directory
    Note
    • You can mount a share over IPv6 only in the China (Hohhot) region. Make sure that the virtual private cloud (VPC) and vSwitch of the gateway support IPv6.

    • If you want to mount a share over IPv6, make sure that an IPv6 address is configured for the client on the ECS instance.

    • If the VPC and vSwitch of an existing gateway support IPv6, you can obtain an IPv6 mount target after you enable IPv6 support for the gateway. By default, new gateways created in this IPv6-compatible VPC support IPv6.

    Command description:

    • 192.168.0.0:/shares is the gateway mount target, which consists of the IP address of the gateway and the share of the gateway. Replace them with your actual information. You can check the mount target of a gateway on the Share page of the gateway in the Cloud Storage Gateway (CSG) console.

    • [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares is the gateway mount target, which consists of the IPv6 address and the share of the gateway. Replace them with your actual information. You can check the mount target of a gateway on the Share page of the gateway in the CSG console.

    • local-directory is the local directory of the client. You must specify a directory that supports read and write operations. You cannot specify a directory that does not exist.

    • noac specifies that the client obtains the file system metadata from the gateway in real time. You can specify the noac parameter in the mount command if the express synchronization feature is enabled and the share that you want to mount is added to an express synchronization group. This allows you to check the synchronization result on the client at the earliest opportunity. This parameter has an observable impact on the read/write performance of the client. If you need to monitor data changes for the client, we recommend that you specify this parameter. If the client requires high write/read performance, we recommend that you do not specify this parameter. The following sample command includes the noac parameter:

      mount.nfs -o noac 192.168.0.0/shares local-directory
  4. Run the df -h command to view the mount result.

    If the output is similar to the following information, the NFS share is mounted.

    guazai

    Note

    After the NFS share is mounted, you can view the capacity of the file system that is managed by the NFS share. Object Storage Service (OSS) provides unlimited storage capacity. For the file system capacity supported for individual gateway specifications, see Specifications.

Access an NFS share

After an NFS share is mounted, you can access the NFS share in the same way that you access a local directory. If you have write permissions on the share, you can write data to the share. If you have read-only permissions on the share, you can only read data from the share.

Note

A share of a gateway is synchronized with the OSS bucket associated with the share. When you perform operations on a share, the changes to the share are also applied to the associated OSS bucket.

Unmount a share

To unmount a share, run the umount local-directory command, where local-directory is the local directory on which the share is mounted.

Automatically mount an NFS share

If you manually mount an NFS share to a Linux client, the NFS share mount does not persist after a client restart. You can configure the Linux client to automatically mount an NFS share on client startup by using the /etc/fstab (recommended) or /etc/rc.local file.

Note

Before you configure a share to be automatically mounted, make sure that you have manually mounted the share. This prevents automatic mount failures after a client restart.

  1. Open the configuration file and add the mount configurations.

    • Method 1 (recommend): Open the /etc/fstab configuration file and add the mount configurations.

      Note

      If your client runs CentOS 6, perform the following steps first:

      1. Run the chkconfig netfs on command to enable NetFS startup upon system boot.

      2. Open the /etc/netconfig file and comment out inet6-related information.

      • To mount the NFS share by using NFS version 4, add the following mount configurations:

        • IPv4:

          192.168.0.0:/shares local-directory nfs defaults 0 0
        • IPv6:

          [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares local-directory nfs defaults 0 0
      • To mount the NFS share by using NFS version 3, add the following mount configurations:

        • IPv4:

          192.168.0.0:/shares local-directory nfs vers=3.0 defaults 0 0
        • IPv6:

          [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares local-directory nfs vers=3.0 defaults 0 0
    • Method 2: Open the /etc/rc.local configuration file and add the mount configurations.

      Note

      Before you edit the /etc/rc.local file, make sure that you have the execute permission on the /etc/rc.local and /etc/rc.d/rc.local. For example, in CentOS 7.x, the execute permission is not granted by default. You must obtain the execute permission to edit the /etc/rc.local file.

      • To mount the NFS share by using NFS version 4, add the following mount configurations:

        • IPv4:

          sudo mount.nfs 192.168.0.0:/shares local-directory
        • IPv6:

          sudo mount.nfs [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares local-directory
      • To mount the NFS share by using NFS version 3, add the following mount configurations:

        • IPv4:

          sudo mount -t nfs -o vers=3,proto=tcp,nolock 192.168.0.0:/shares local-directory
        • IPv6:

          sudo mount -t nfs -o vers=3,proto=tcp,nolock [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares local-directory

    Command description:

    • 192.168.0.0:/shares is the gateway mount target, which consists of the IP address of the gateway and the share of the gateway. Replace them with your actual information. You can check the mount target of a gateway on the Share page of the gateway in the Cloud Storage Gateway (CSG) console.

    • [2408:4004:ffff:ffff:ffff:ffff:ffff:ffff]:/shares is the gateway mount target, which consists of the IPv6 address and the share of the gateway. Replace them with your actual information. You can check the mount target of a gateway on the Share page of the gateway in the CSG console.

    • local-directory is the local directory of the client. You must specify a directory that supports read and write operations. You cannot specify a directory that does not exist.

    • noac specifies that the client obtains the file system metadata from the gateway in real time. You can specify the noac parameter in the mount command if the express synchronization feature is enabled and the share that you want to mount is added to an express synchronization group. This allows you to check the synchronization result on the client at the earliest opportunity. This parameter has an observable impact on the read/write performance of the client. If you need to monitor data changes for the client, we recommend that you specify this parameter. If the client requires high write/read performance, we recommend that you do not specify this parameter. The following sample command includes the noac parameter:

      mount.nfs -o noac 192.168.0.0/shares local-directory
  2. Run the reboot command to restart the ECS instance.