Updated on 2023-05-10 GMT+08:00

Creating a Local Directory for a File System

After creating a file system, you need to mount the file system to an ECS and create a local directory for the root user.

If the file system has been mounted, skip this section. Record the local directory in 4 and perform steps in Creating a Readable and Writable Subdirectory on the File System for Each User.

Prerequisites

  • You have checked the type of the ECS operating system. Different operating systems require different commands for NFS client installation.
  • You have created a file system and have obtained the mount point of the file system.
  • The ECS to which a file system is mounted belongs to the same VPC as the file system.
  • The IP addresses of the DNS server used to resolve the file system domain name have been configured on the ECS.

Procedure

  1. Create an ECS running CentOS in AZ2 of the CN North-Beijing1 region, for example, ecs-whm. See Figure 1.

    Figure 1 Creating an ECS

  2. Log in to the ECS as user root. Install the NFS client.

    1. Run the following command to check whether the NFS software package is installed.
      • On CentOS, Red Hat, Oracle Enterprise Linux, SUSE, Euler OS, Fedora, or OpenSUSE:

        rpm -qa|grep nfs

      • On Debian or Ubuntu:

        dpkg -l nfs-common

      If a command output similar to the following is displayed, the NFS software package has been installed and you can go to Step 3. If nothing is displayed, go to Step 2.2.
      • On CentOS, Red Hat, Euler OS, Fedora, or Oracle Enterprise Linux:
        libnfsidmap
        nfs-utils
      • On SUSE or OpenSUSE:
        nfsidmap
        nfs-client
      • On Debian or Ubuntu:
        nfs-common
    2. Run the following command to install the NFS software package.

      The following commands require that the ECS be connected to the Internet. Otherwise, the installation will fail.

      • On CentOS, Red Hat, Euler OS, Fedora, or Oracle Enterprise Linux:

        sudo yum -y install nfs-utils

      • On Debian or Ubuntu:

        sudo apt-get install nfs-common

      • On SUSE or OpenSUSE:

        zypper install nfs-client

  3. Run the following command to check whether the domain name in the file system mount point can be resolved. See Figure 2.

    nslookup File system domain name

    nslookup sfs-nas1.xx-xxxx-xx.xxxxxxxxxxx.com
    • A file system domain name is just a part of the mount point, for example, sfs-nas1.xxxx.com. You can obtain a file system domain name from the mount point of a file system. In this step, you are not supposed to enter the entire mount point but only the domain name.
    • If the nslookup command cannot be used, install the bind-utils software package by running the yum install bind-utils command.
    • If the resolution succeeds, go to 4.
    • If the domain name cannot be resolved, configure the DNS server IP address and then mount the file system. For details, see Configuring DNS.
    Figure 2 Domain name resolution

  4. Run the following command to create a local directory for mounting the file system. Record the local directory name, for example, root001.

    mkdir Local directory

    mkdir root001

  5. Run the following command to mount the file system to the ECS. SFS supports mounting only file systems complying with NFSv3 to ECSs running Linux. Table 1 describes the variables.

    mount -t nfs -o vers=3,timeo=600,nolock Mount point Local directory

    After an ECS that has mounted file systems restarts, it loses the file system mount information. You can configure automatic mount in the fstab file to ensure that an ECS automatically mounts file systems when it restarts. For details, see Mounting a File System Automatically.

    Table 1 Parameters

    Parameter

    Description

    vers

    File system version. Currently, only NFSv3 is supported, so the value is fixed to 3.

    timeo

    Waiting time before the NFS client retransmits a request. The unit is 0.1 second. Recommended value: 600

    lock/nolock

    Whether to lock files on the server using the NLM protocol. If nolock is selected, the lock is valid for applications on one host. For applications on another host, the lock is invalid. Recommended value: nolock

    Mount point

    The format for an SFS file system is File system domain name:/Path, for example, example.com:/share-xxx. The format for an SFS Turbo file system is File system IP address:/, for example, 192.168.0.0:/.

    NOTE:

    x can be a digit or letter.

    If the mount point is too long to display completely, expand the column to view the full mount point.

    Local directory

    Local directory on the ECS, used to mount the file system, for example, /local_path.

    Figure 3 Mount point

  6. Run the following command to view the mounted file system:

    mount -l

    If the command output contains the following information, the file system is mounted successfully.
    example.com:/share-xxx on /local_path type nfs (rw,vers=3,timeo=600,nolock,addr=)

  7. After the mounting is successful, create a common user and subdirectory by referring to the next section.

    If the mounting fails or times out, rectify the fault. For details, see Troubleshooting.

    The supported maximum size of a file to be written is 240 TB.