All Products
Search
Document Center

Cloud Storage Gateway:Access an NFS share

Last Updated:Mar 18, 2024

This topic describes how to access on-premises gateways from a Linux client.

Prerequisites

A Network File System (NFS) share is created. For more information, see Install an NFS client.

Background information

  • To access an on-premises gateway from a Linux client, you must mount the NFS share to a local file directory. After the share is mounted, a mapping is established between the share and the local directory. You can access the share in the same way you access an on-premises directory.

  • In Linux, NFS file systems can be mounted manually and automatically. A manual NFS share mount does not persist after a client restart. We recommend that you first manually mount an NFS share and then configure the share to be automatically mounted after a client restart.

Manually mount an NFS share

  1. Log on to your local Linux client.

  2. Mount the NFS share to the local directory on your Linux client.

    • To mount a share by using NFSv4, run the following command:

      sudo mount -t nfs -o vers=4.0,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 192.168.0.0:/shares local-directory
    • To mount a share by using NFSv3, perform the following steps:

      1. Run the following command to obtain the mount target.

        showmount -e <gateway IP address>
      2. Run the following command to mount the share (in this example, the mount target is 192.168.0.0:/shares):

        sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 192.168.0.0:/shares local-directory
  3. Note

    In the preceding mount commands:

    • 192.168.0.0:/shares is the mount target that includes the IP address of the gateway and the share of the gateway. Replace the mount target 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.

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

  4. Run the df -h command to check the mount result.

    If the returned result is similar to the following output, the NFS share is mounted to the local directory of the client.

    Note

    The capacity of the mounted share is equal to the capacity of the Object Storage Service (OSS) bucket. The displayed capacity 256 TB is the maximum capacity of the file system. OSS storage capacity is not limited.

    挂载结果

  5. Access the share.

    After an SMB share is mounted, you can access the SMB 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 is synchronized with its associated OSS bucket. If you perform operations on a share, changes are also made to the objects in the associated bucket.

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 after a client restart by using the /etc/fstab (recommended) or /etc/rc.local file.

Important

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

  1. Add 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 chkconfg 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 NFSv4, add the following mount configurations:

        192.168.0.0:/shares local-directory nfs vers=4.0 defaults 0 0
      • To mount the NFS share by using NFSv3, add the following mount configurations:

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

      In the preceding mount commands:

      • 192.168.0.0:/shares is the mount target that includes the IP address of the gateway and the share of the gateway. Replace the mount target 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.

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

    • Method 2: Open the /etc/rc.local configuration file and add the mount configurations.

      Note

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

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

        sudo mount -t nfs -o vers=4.0,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 192.168.0.0:/shares local-directory
      • To mount the NFS share by using NFSv3, add the following mount configurations:

        sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 192.168.0.0:/shares local-directory
    • Note

      In the preceding mount commands:

      • 192.168.0.0:/shares is the mount target that includes the IP address of the gateway and the share of the gateway. Replace the mount target 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.

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

  2. Run the reboot command to restart the client.

  3. Run the df -h command to check the mount result.