How do I modify the maximum number of concurrent NFS requests?

By default, the maximum number of concurrent requests from a Network File System (NFS) agent is 2. This reduces the performance of NFS file systems. We recommend that you set the maximum number to 128.

  • Method 1
    1. Install an NFS client. For more information, see Install an NFS client.
    2. Run the following commands to set the maximum number of concurrent NFS requests to 128.
      echo "options sunrpc tcp_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf
      echo "options sunrpc tcp_max_slot_table_entries=128" >>  /etc/modprobe.d/sunrpc.conf
      Note The first time you install an NFS agent, run the preceding commands once with root permissions. You do not need to run the commands again.
    3. Use the following command to restart the ECS instance.
      reboot
    4. Mount the NAS file system to the ACK cluster. For more information, see Precautions.
    5. Use the following command to verify the results.
      If the value 128 is returned, the maximum number is modified.
      cat /proc/sys/sunrpc/tcp_slot_table_entries
  • Method 2
    1. Install an NFS client. For more information, see Install an NFS client.
    2. Run the following commands to set the maximum number of concurrent NFS requests to 128.
      echo "options sunrpc tcp_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf
      echo "options sunrpc tcp_max_slot_table_entries=128" >>  /etc/modprobe.d/sunrpc.conf
      Note The first time you install an NFS agent, run the preceding commands once with root permissions. You do not need to run the commands again.
    3. Remount the file system. For more information, see Precautions.
    4. Use the following command to verify the results.
      If the value 128 is returned, the maximum number is modified.
      cat /proc/sys/sunrpc/tcp_slot_table_entries

How do I create and mount a subdirectory of a NAS file system on Linux?

Make sure that a file system is mounted. For more information, see Mount an NFS file system on a Linux ECS instance.

If you mount the /mnt directory of the file system on a Linux ECS instance, the /mnt directory is used as the root directory of the file system. You can create subdirectories in the /mnt directory.

  1. Create a subdirectory in the root directory of the NAS file system on the server, for example, a Linux ECS instance.
    mkdir /mnt/subdir
  2. Create a local directory on which you can mount the NAS file system.
    mkdir /tmp/mnt
    Note After you create a local directory on a server, you can mount only one file system on the local directory. To mount multiple file systems, you must create multiple local directories.
  3. Remount the file system.
    sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt
    The following list describes the required fields. Replace the values of these fields with the actual values.
    • file-system-id.region.nas.aliyuncs.com: specifies the endpoint of the mount target. To obtain the mount target, perform the following operations: Log on to the NAS console. On theFile System List page, click the name of the file system. On the details page, click Mounting Use and copy the mount command.
    • /subdir: specifies the subdirectory of the NAS file system.
    • /tmp/mnt: specifies the local directory of the server.

I accidentally deleted a mount target on an ECS instance that runs Linux, and issues started to occur. How do I fix these issues?

  • Issue

    A file system is mounted on a Linux ECS instance by using Mount Target A. However, the mount target is deleted from the NAS console before the file system is unmounted. As a result, issues occur on Linux. For example, the system gives slow responses or does not respond when you run commands.

  • Solution
    1. On the Linux ECS instance, press Ctrl+C to stop the commands that are being run.
    2. Run the mount command to view the mount information.
      Obtain the mount directory from the mount information, for example, /mnt/data, as shown in the following figure. View the mount information
    3. Run the umount -f /mnt/data command to unmount the file system.
      Command syntax: unmount-f <Mount directory>
      Note If the unmount -f <Mount directory> command fails to unmount the file system, run the umount -l <Mount directory> command.
      After you unmount the file system, you can create a mount target to mount the file system.

How do I prevent the listening port of a file system that supports NFSv4.0 protocol from being mistaken for a Trojan horse?

  • Issue

    After you mount a file system that supports the NFSv4.0 protocol on a compute node, the protocol listens to the random listening port 0.0.0.0. The netstat command cannot identify the process of the listening port.

    This is because the listening port is a random port, and therefore the backend application of the listening port cannot be traced. As a result, the listening port is mistaken for a Trojan horse.

  • Cause

    The NFSv4.0 protocol listens to this random port for callback operations. By default, the fs.nfs.nfs_callback_tcpport kernel parameter is set to 0. Therefore, the NFSv4.0 protocol listens to a random port. This random port does not cause security risks.

  • Solution
    Before you mount the file system, you can specify a non-zero value for the fs.nfs.nfs_callback_tcpport parameter. The non-zero value is used as the port number of the callback port.
    sudo sysctl fs.nfs.nfs_callback_tcpport=<port>          

    In the following example, the fs.nfs.nfs_callback_tcpport parameter is set to 45450. After you mount a file system that supports the NFSv4.0 protocol, the result that is returned by the netstat command indicates that the system listens to port 45450. The root user is used in this example, as shown in the following figure. Therefore, you do not need to use sudo to run the sysctl command.

Why am I unable to use a Linux client to read data from or write data to files that are named in Chinese characters in a file system?

The files that are named in Chinese characters in a file system are created on a Windows client. The names of these files are in the GBK format. By default, Linux clients can recognize only file names that are in the UTF-8 format. Therefore, Linux clients cannot recognize files that are named in Chinese characters. We recommend that you use a Windows client to read data from and write data to the files that are named in Chinese characters.

Why is a 523 error returned when I run the ls command on a Linux client on which an NFS file system is mounted?

  • Issue
    The following error message is returned when you run the ls command on a Linux client on which an NFS file system is mounted: 29
  • Cause

    If you run the ls command on a directory of a file system while multiple rename operations are concurrently called, a 523 error occurs.

  • Solution

    Try again later. If the error persists, submit a ticket.

How do I fix the error that occurs when I mount an SMB file system on Windows?

  1. System error 53
    • Error message

      The network path is not found.

    • Cause
      • The network connection fails.
      • The TCP/IP NetBIOS Helper service is not started.
      • LanmanWorkstation is not specified in the registry.
    • Solution
      1. Run the ping <Endpoint of a mount target> command to check whether the endpoint of a mount target is accessible and whether the latency is within the expected range.
        • If you can ping the endpoint of the mount target, go to Step 2.
        • Otherwise, perform the following steps:
          • Make sure that the mount command is valid. For example, check whether the command does not include redundant forward slashes (/), backslashes (\), spaces, or myshare.
            To run a valid command to mount an SMB file system, use the following syntax:
            net use <Letter of the destination drive> \\<Endpoint of a mount target>\myshare
            Example:
            net use z: \\xxxx.cn-hangzhou.nas.aliyuncs.com\myshare 
          • Make sure that the protocol type of the file system is SMB.
          • Make sure that the endpoint of the mount target is valid.
          • Make sure that the Elastic Compute Service (ECS) instance and the mount target reside in the same virtual private cloud (VPC).
          • If the ECS instance and the mount target do not reside in the same VPC, make sure that the VPC or virtual private network (VPN) configurations of the ECS instance are valid.
      2. Run the telnet <Endpoint of a mount target> 445 command to check whether the SMB protocol is enabled.
      3. Check whether the TCP/IP NetBIOS Helper service is started. For more information, see Mount an SMB file system on Windows.
      4. Open the Registry Editor, choose HKEY_LOCAL_MACHINE > System > CurrentControlSet > Control > NetworkProvider > Order. In the dialog box that appears, check whether the ProviderOrder key contains the LanmanWorkstation value. If the ProviderOrder key does not contain the LanmanWorkstation value, add the value to the ProviderOrder key. Check the Windows registry
  2. System error 58
    • Error message

      The specified server cannot perform the requested operation.

    • Cause

      The Windows operating system that the ECS instance runs is incompatible with the SMB protocol that is used by the file system.

    • Solution

      Make sure that the ECS instance runs Windows Server 2008 R2 or a later version, excluding Windows Server 2008.

  3. System error 64
    • Error message

      The specified network name is unavailable.

    • Cause
      • The IP address of the ECS instance is not included in the permission groups of the NAS file system.
      • The internal IP address or VPC IP address of the ECS instance is not included in the permission groups of the NAS file system.
      • Your Alibaba Cloud account has overdue payments.
      • The ECS instance and the NAS file system reside in the classic network. However, the ECS instance and the NAS file system belong to different Alibaba Cloud accounts.
      • The protocol type of the file system is not SMB.
    • Solution
      This error occurs because the NAS file system is inaccessible. Perform the following steps to fix the error:
      1. Make sure that the internal IP address or VPC IP address of the ECS instance is included in the permission groups of the NAS file system.
      2. Make sure that your Alibaba Cloud account does not have overdue payments.
      3. If the ECS instance and the NAS file system reside in the classic network, make sure that they belong to the same Alibaba Cloud account.
      4. Make sure that the protocol type of the file system is SMB. System error 64
  4. System error 67
    • Error message

      The network name cannot be found.

    • Cause

      The required network services are not started.

    • Solution
      Start the following services. For more information, see Mount an SMB file system on Windows.
      1. The Workstation service.
      2. The TCP/IP NetBIOS Helper service.
  5. System error 85
    • Error message

      The local device name is already in use.

    • Cause

      The specified drive letter is already in use.

    • Solution

      Change the drive letter and remount the file system.

  6. System error 1231
    • Error message

      The network location is unavailable.

    • Cause
      • The Client for Microsoft Networks component is uninstalled or disabled.
      • The File and Printer Sharing for Microsoft Networks component is uninstalled or disabled.
    • Solution

      Install and enable the Client for Microsoft Networks component or the File and Printer Sharing for Microsoft Networks component.

      If the Client for Microsoft Networks component or the File and Printer Sharing for Microsoft Networks component is installed but not enabled, select the Client for Microsoft Networks option or the File and Printer Sharing for Microsoft Networks option. Perform the following steps to install and enable the component:

      System error 1231
      1. On the Network and Sharing Center page, click the active network connection.
      2. Click Properties.
      3. In the WLAN Properties dialog box, click Install.
        • Install the Client for Microsoft Networks component.
          1. In the Select Network Feature Type dialog box, select Client, and click Add.
          2. Select Client for Microsoft Networks and click OK.
        • Install the File and Printer Sharing for Microsoft Networks component.
          1. In the Select Network Feature Type dialog box, select Service, and click Add.
          2. Choose Microsoft > File and Printer Sharing for Microsoft and click OK.
  7. System error 1272
    • Error message

      You cannot access this shared folder because the security policies of your organization block access from unauthorized guests. These policies protect your PC from unsafe or malicious devices on the network.

    • Cause

      The security policies of the Windows operating system block access from guest users to the SMB file system.

    • Solution
      If the ECS instance runs a Windows operating system that is later than Windows Server 2016, excluding Windows Server 2016, configure the following registry to allow access from guest users:
      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]
      "AllowInsecureGuestAuth"=dword:1
      For more information, see Guest access in SMB2 disabled by default in Windows.

Why does a file in a NAS file system belong to different owners when I query the file on two ECS instances?

In NAS file systems, users are identified by User Identifiers (UIDs) or Group Identifiers (GIDs) instead of user names. The owner name that you query on the ECS instance is converted from a UID. If a UID is converted into different user names on different ECS instances, the UID is identified as a different owner on each ECS instance.

For example, create a file named admin_on_machine1 on ECS Instance 1 and a file named admin_on_machine2 on ECS Instance 2 as the admin user. Run the ls -l command on ECS Instance 1 to view the created file, as shown in the following figure.faq001Run the ls -l command on ECS Instance 2 to view the created file, as shown in the following figure.faq002The query results on the two ECS instances indicate that the same file has different owner names.
Run the id command on the two ECS instances to query the admin user. The UID of the admin user on ECS Instance 1 is 505, as shown in the following figure.faq04The UID of the admin user on ECS Instance 2 is 2915, as shown in the following figure.faq005Run the stat admin_on_machine1 admin_on_machine2 command, as shown in the following figure. The results indicate that the two files belong to two different UIDs.faq

Why am I unable to mount an SMB file system on a Windows operating system that is later than Windows Server 2016?

  • Issue

    An error occurs when you run the following command:

    C:\Users\Administrator>net use z: \\xxxxx-xxxx.xxxxx.nas.aliyuncs.com\myshare
    System error 1272 has occurred.
    You can't access this shared folder because your organization's security policies block unauthenticated guest access. These policies help protect your PC from unsafe or malicious devices on the network.
  • Solution

    This error occurs because the security policies of a Windows operating systems that are later than Windows Server 2016 do not allow guest users to access remote shared directories.

    Perform the following steps to fix the error:

    • Locate the following registry key:
      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]
      "AllowInsecureGuestAuth"=dword:0

      Modify the key.

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]
      "AllowInsecureGuestAuth"=dword:1
    • Open PowerShell and run the following command:
      New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force

    For more information, see Guest access in SMB2 disabled by default in Windows 10, Windows Server 2016 version 1709, and Windows Server 2019.

Why am I unable to mount an SMB file system?

  • Issue

    The net use command is used to mount SMB file systems. If you accidentally use the command to mount NFS file systems, you can no longer use the command to mount an SMB file system.

  • Solution

    Make sure that the protocol of the file system is SMB. Then, stop the mount operation and try to mount the file system again after 5 minutes. If the issue persists, submit a ticket.

Why is a mounted SMB directory visible only to an administrator?

This issue occurs because Windows user accounts are isolated from each other. For example, if you log on to Windows as User A, you cannot view the directory that you mounted as User B.

To enable access from multiple users, create a shared directory. For example, you can run the following command to create a shared directory named myshare on drive C:
mklink /D C:\myshare \\xxxxxxx-xxxx.cn-beijing.nas.aliyuncs.com\myshare\

Why is Internet Information Services (IIS) unable to load the files of an SMB volume on Windows Server 2016?

For more information about how to fix this issue, see Install and configure Active Directory domains.

How do I fix the error that occurs when I use IIS to access a NAS file system?

When you mount an SMB file system on Windows Server 2016, an HTTP error 500.19 (error code 0x8007003a) occurs. For information about how to fix this error, see Best practices for using IIS to access a NAS file system.

Can I mount an NFS file system and SMB file system on the same ECS instance?

No, you cannot mount an NFS file system and SMB file system on the same ECS instance.

To prevent compatibility issues, we recommend that you do not access an SMB file system by using a Linux client. For example, the supported character sets and the length of a file name for Windows and Linux are different. In Windows, a maximum length of 255 Unicode wide characters is supported. In Linux, a maximum length of 255 UTF-8 characters is supported.

To mount an NFS file system and an SMB file system on the same ECS instance, you can mount the SMB file system on a Linux ECS instance. The kernel of the Linux ECS instance must support SMBv2 or a later version.

Run one of the following mount commands: mount -t cifs -o vers=2.0 \\<Mount target>\myshare /mnt or mount -t cifs -o vers=2.0 //<Mount target>/myshare /mnt.
Note If you are prompted to enter a password after you run the commands, press Enter.

To check whether your Linux kernel supports the CIFS protocol, view the value of CONFIG_CIFS in the /boot directory. A value of y or m indicates that the protocol is supported and a CIFS file system can be mounted.

Note
  • Before you run the preceding command, you must install the cifs-utils tool. For example, you can run the following command to install the cifs-utils tool on CentOS:
    yum install samba-client samba-common cifs-utils
  • If the CIFS protocol is not supported on your version of Linux, we recommend that you upgrade the Linux kernel to version 3.10.0-514 or later.

Why am I unable to mount an SMB file system on Linux?

Cause
  • You are using an early or incompatible version of Linux distributions. SMB file systems support the following Linux distributions:
    • CentOS 7.6 64-bit (3.10.0-957.5.1.el7.x86_64)
    • Ubuntu 18.04 64-bit (4.15.0-48-generic)
    • Debian 9.9 64-bit (4.9.0-9-amd64)
    • SUSE Enterprise Server 12 SP2 64-bit (4.4.74-92.35-default)
    • openSUSE 42.3 64-bit (4.4.90-28-default)
    • Alibaba Cloud Linux (4.19.34-11.al7.x86_64)
    • CoreOS (4.19.43-coreos VersionID=2079.4.0)
  • The cifs-utils tool is not installed on the client, or the executable file of the mount.cifs command is stored in a directory that is different from the directory specified by the PATH environment variable.
  • No network connection is established between the Linux ECS instance and the SMB file system.
    • The Linux ECS instance and the SMB file system belong to different Alibaba Cloud accounts.
    • The Linux ECS instance and the SMB file system reside in different regions.
    • The Linux ECS instance and the SMB file system reside in different networks. For example, the Linux ECS instance and the SMB file system reside in different VPCs or one of them resides in a VPC and the other resides in the classic network.
      Note You can mount a NAS file system on an on-premises Linux client. If you cannot access the file system from the Linux client, a probable cause is that no network connection is established between the Linux client and the file system. To establish a network connection, use Express Connect.
    • The IP address of the Linux ECS instance is not included in the permission groups of the SMB file system.
    • The firewall of the Linux ECS instance denies access to the IP address or port 445 of the SMB file system.
    • The Linux ECS instance attempts to connect with the SMB file system by using an unsupported Transmission Control Protocol (TCP) port. SMB file systems support only port 445.
    Note

    You can run the ping <VolumeDomainName> and telnet <VolumeDomainName>445 commands to check the network connectivity.

    If port 445 is disabled, you must add rules for port 445 to a security group of the ECS instance. For more information, see Add security group rules.

  • The account that you use to log on to the Linux ECS instance does not have the root permissions or is not authorized to run the mount command. You can run the sudo command to authorize the account to run the mount command.
  • The file system type is not set to Common Internet File System (CIFS).
  • The value of the vers parameter in the mount command is not 2.0.
  • The identity of the guest user is not specified when the NAS file system is mounted.
  • The specified value for uid, gid, dir_mode, or file_mode is invalid.
  • The Security-Enhanced Linux (SELinux) settings for the mount directory are invalid.
  • The file system is mounted on more than 1,000 ECS instances that run Linux. This issue often occurs when you mount a file system on containers.
Solution
  1. Fix the issue based on the preceding causes. For more information, see Mount an SMB file system on a Linux ECS instance.
  2. Fix the issue based on the /var/log/messages file and the output of the dmesg command.
  3. Submit a ticket to contact Alibaba Cloud for technical support.

    When you submit a ticket, you must provide the version of your Linux distribution, mount commands, /var/log/messages file, and output of the dmesg command.

How do I improve the performance of an SMB file system that is mounted on Linux?

If the performance of your SMB file system cannot meet your requirements, you can use the following solutions based on specific causes:

  • Cause 1: The maximum read/write throughput of the SMB file system has a linear relationship with the capacity of the file system.

    Solution: Use the fio tool to test the performance of the SMB file system. For more information, see Performance testing for Apsara File Storage NAS.

  • Cause 2: The bandwidth of the Linux ECS instance is low.

    Solution: Use multiple Linux ECS instances to ensure that the file system can provide expected performance.

  • Cause 3: Caching is disabled for the SMB client.

    Solution: If the cache parameter is set to strict, caching is enabled. If the cache parameter is set to none, caching is disabled. By default, caching for an SMB client is enabled. You can run the sudo mount | grep cifs command to check the value of the cache parameter.

  • Cause 4: The I/O size of the SMB client does not meet your business requirements.

    Solution: Specify the rsize and wsize parameters based on your business requirements. The default value of the two parameters is 1048576.

  • Cause 5: The Linux ECS instance uses low-specification CPU or memory, or most CPU or memory resources are occupied by other processes.

    Solution: Specify the required specifications for the Linux ECS instance based on the usage of CPU and memory resources. This ensures that the file system can function as expected. You can run the top command to check the usage of CPU and memory resources.

  • Cause 6: The atime parameter is specified when you mount the file system.

    Solution: Do not specify the atime parameter if your business does not require fast file access.

  • Cause 7: The web server such as Apache HTTP Server on the Linux ECS instance processes a few write requests. These requests require notifications and frequent read operations on a large number of small files.

    Solution: Configure the caching mechanism of the web server on the Linux ECS instance. You can also contact Alibaba Cloud to enable the acceleration feature for the web server.

Why does file migration and replication take a long time when I mount an SMB file system on Linux?

Check whether the file system provides poor performance. If the performance of the file system can meet your requirements, a probable cause is that the files are not concurrently migrated or replicated. You can use the following open source tools to migrate or replicate files.

  • GNU Parallel

    Specify a number of threads based on your system resources. Example: find * -type | parallel --will-cite -j 10 cp {} /mnt/smb/ &

  • Fpart
  • Fpsync
  • multi

How do I fix the Permission denied error when I access an SMB file system on Linux?

Cause: You specified an invalid value for the uid, gid, file_mode, or dir_mode parameter when you mounted the file system.

Solution: Check whether the values that are specified for the uid, gid, file_mode, and dir_mode parameters are valid. For more information, see Mount an SMB file system on a Linux ECS instance.

How do I rename the files of an SMB file system by changing the letter case?

The file names of an SMB file system are case-insensitive. This also applies to Windows systems. A file in an SMB file system cannot be renamed by changing only the letter case.

However, you can change a file name to a different name that includes different letters. Then, you can change the file name to the original name with a different letter case.

Why am I unable to change the owner of a file and access mode of a file or directory?

You can specify the owner of a file and access mode of a file or directory in a file system only when you mount the file system. For more information, see Mount an SMB file system on a Linux ECS instance.

Why does the server not respond within 35 seconds when multiple clients concurrently access a file?

Cause: The kernel driver of the current SMB protocol fails to work as expected. If the SMB protocol version is 2.1 or 3.0, the server does not respond within 35 seconds. In this case, the clients cannot send SMB break acknowledgment packets to the server.

Solution 1: Set the vers parameter to 2.0 if you mount the file system on the Linux ECS instance.

Solution 2: Perform the following operations:
  1. If the CIFS module is being loaded, run the following command to disable the oplock feature:

    # modprobe cifs enable_oplocks=0

  2. If the CIFS module is already loaded, run the following command to disable the oplock feature:

    # echo 0 > /sys/module/cifs/parameters/enable_oplocks

  3. Run the following command to check the status of the oplock feature:

    # cat /sys/module/cifs/parameters/enable_oplocks

    In the result, Y indicates that the feature is enabled. N indicates that the feature is disabled.

    Note
    • To apply the preceding changes, unmount and remount the SMB file system.
    • To permanently apply the preceding changes, create the /etc/modprobe.d/cifs.conf file and add the options cifs enable_oplocks=0 statement to the file.

Why does the mount target of an SMB file system become unresponsive?

Cause: If the kernel version of your Linux distribution is 3.10.0-514 or earlier, the kernel driver of the SMB protocol may fail to respond when multiple clients concurrently access the file system. In this case, the mount target is inaccessible. The following record is included in the kernel log:
...
[<ffffffffc03c9bc1>] cifs_oplock_break+0x1f1/0x270 [cifs]
[<ffffffff810a881a>] process_one_work+0x17a/0x440
[<ffffffff810a8d74>] rescuer_thread+0x294/0x3c0
...
Solution
  • Set the cache parameter to none to remount the file system. This may affect the performance of the file system.
  • Upgrade the operating system of the Linux ECS instance.

How do I fix the error that occurs when I mount an NFS file system on Windows?

  • Error message: Invalid file handler

    Solution: Perform the required steps and set the parameters to remount the file system. For more information, see Mount an NFS file system on an ECS Windows instance.

  • Error message: Network error 53

    Solution: Perform required steps and set the parameters to remount the file system. For more information, see Mounting NFS on a Windows Client.

  • Error message: Network error 1222MISTAKE

    Solution: After you install an NFS client, remount the file system. For more information, see Install the NFS client.

How do I fix the errors that occur when I soft mount an NFS file system on Windows?

  • Issue
    By default, the soft mode is used when you mount an NFS file system on Windows. However, in some scenarios, soft mounts result in data inconsistency or unexpected application exits.
    • Data inconsistency: An application sends an ECS instance a request to write data to a soft-mounted file system. If the application does not receive a response from the instance before the request times out, an error is returned. This applies even if data is written to the file system. In this case, the application determines that the request failed. However, the ECS instance determines that the request is successful. As a result, data inconsistency occurs.
    • Unexpected application exits: An application sends an ECS instance a request to access a soft-mounted file system. If the application does not receive a response from the instance before the request times out, an error is returned. In this case, an exception may be thrown based on the programming language that is used to write the application. If the exception is not handled, the application exits.
  • Solution 2
    To prevent these issues, hard mount the NFS file system on the ECS Windows instance.
    1. Run the mount command to view the mount mode.
      • If the command output includes mount=soft, perform the following steps.
      • If the command output includes mount=hard, you do not need to perform the following steps.
    2. Stop the application that is using the NFS file system.
    3. Run the following command to unmount the NFS file system:
      umount H:
      Replace the drive letter H: based on your business requirements.
    4. Run the following command to remount the NFS file system:
      mount -o nolock -o mtype=hard -o timeout=60 \\xxxxxx.cn-hangzhou.nas.aliyuncs.com\! h:
      Replace the mount target address xxxxxx.cn-hangzhou.nas.aliyuncs.com and the drive letter h: based on your business requirements.
    5. Run the mount command to verify the mount result:
      The mount is successful if the command output includes mount=hard, locking=no, and timeout=10 or a number greater than 10.

How do I resolve the invalid device error that is returned when I try to rename a file on the Windows NFS client?

If you mount the NFS file system on a subdirectory of the ECS instance, the invalid device error is returned when you rename the file. To prevent this error, mount the file system on the root directory of the ECS instance.

If the system fails to terminate processes that connect to a file system, how do I clear the handles that are exposed by a client?

To release all handles, you can use the following tool to remove all connections from an SMB file system.
  • Windows client
    Use the tcpview tool to remove all connections from an SMB file system. For more information, see tcpview. 4
  • Linux client

    Use the killcx tool to remove all connections from an SMB file system. For more information, see killcx.

How do I prevent exceptions if multiple processes or clients concurrently write data to a log file?

  • Issue

    NAS allows multiple clients to write data to different files in the same namespace over NFS. However, NFS does not support atomic appends. Some exceptions may occur if multiple processes or clients concurrently write data to the same file. This is because each process independently maintains context information. The file can be a log file. The context information includes file descriptors and write locations. These exceptions include overwrite, crossover, and disordered content.

  • Solution
    • Recommended. Use different processes or clients to write data to different files in the same file system. When you analyze or process data, you can consolidate these files. This solution can fix the issues that are caused by concurrent write operations without the need to use file locks. In addition, the solution does not affect system performance.
    • Use a combination of the flock and seek functions. This ensures the atomicity and consistency of write operations. However, this solution requires a long period of time and may significantly affect system performance. The following steps describe this method.
  • Use the flock and seek functions together

    NFS does not support atomic appends. If multiple clients append data to the same file such as a log, data entries may overwrite each other. In Linux, you can use the flock and seek functions together to simulate atomic appends on an NFS file system. This ensures data consistency when multiple processes concurrently append data to the same file.

    To use the flock and seek functions together, perform the following steps:
    1. Execute the fd=open(filename, O_WRONLY | O_APPEND | O_DIRECT) statement to open a file by using the append method. This statement is used to set the write method to O_DIRECT and obtain the file descriptor. O_DIRECT specifies a write-only method. In this case, no page cache is used.
    2. Call the flock(fd, LOCK_EX|LOCK_NB) function to obtain a file lock. If the function fails to obtain a file lock, an error message is returned. The failure may occur if the file lock is being used. You can try again or troubleshoot the failure.
    3. After the file lock is obtained, call the lseek(fd, 0, SEEK_END) function to set the current file offset of the file descriptor to the end of the file.
    4. Write data to the file. The insert position is located at the end of the file. The file lock is used to prevent data entries from overwriting each other.
    5. After data is written to the file, call the flock(fd, LOCK_UN) function to release the file lock.
    The following code shows a sample program that is written in C.
    #define _GNU_SOURCE
    #include<stdlib.h>
    #include<stdio.h>
    #include<fcntl.h>
    #include<string.h>
    #include<unistd.h>
    #include<sys/file.h>
    #include<time.h>
    
    const char *OUTPUT_FILE = "/mnt/blog";
    int WRITE_COUNT = 50000;
    
    int do_lock(int fd)
    {
        int ret = -1;
        while (1)
        {
            ret = flock(fd, LOCK_EX | LOCK_NB);
            if (ret == 0)
            {
                break;
            }
            usleep((rand() % 10) * 1000);
        }
        return ret;
    }
    
    int do_unlock(int fd)
    {
        return flock(fd, LOCK_UN);
    }
    
    int main()
    {
            int fd = open(OUTPUT_FILE, O_WRONLY | O_APPEND | O_DIRECT);
            if (fd < 0)
            {
                    printf("Error Open\n");
                    exit(-1);
            }
            for (int i = 0; i < WRITE_COUNT; ++i)
            {
                    char *buf = "one line\n";
    
                    /* Lock file */
                    int ret = do_lock(fd);
                    if (ret != 0)
                    {
                            printf("Lock Error\n");
                            exit(-1);
                    }
    
                    /* Seek to the end */
                    ret = lseek(fd, 0, SEEK_END);
                    if (ret < 0)
                    {
                            printf("Seek Error\n");
                            exit(-1);
                    }
    
                    /* Write to file */
                    int n = write(fd, buf, strlen(buf));
                    if (n <= 0)
                    {
                            printf("Write Error\n");
                            exit(-1);
                    }
    
                    /* Unlock file */
                    ret = do_unlock(fd);
                    if (ret != 0)
                    {
                            printf("UnLock Error\n");
                            exit(-1);
                    }
            }
            return 0;
    }
                
    For more information about how to call the flock() function, see filck().
    Note Only Linux kernel versions 2.6.12 and later support the flock() function. If you use Linux of an earlier kernel version, call the fcntl() function.

Why do I need to mount a NAS file system by using the noresvport parameter?

If network switchovers or high availability (HA) switchovers of backend services occur in a NAS file system, the network connection of the file system may be interrupted. If the network connection is affected, you may need to wait for several minutes for the connection to automatically recover. If the connection fails to automatically recover, you must restart the ECS instance. If you specify the noresvport parameter, the connection can automatically recover within several seconds.

How do I fix issues related to the noresvport parameter?

Note This question applies only to Linux users. If you are a Windows user or you mount NAS file systems by using CSI or Flexvolume plug-ins on Container Service for Kubernetes (ACK) clusters, you can skip this question.
  1. Check whether the noresvport parameter is specified when you mount a file system.
    1. Run the following command on a Linux ECS instance to download the check_noresvport.py script:
      wget -N https://code.aliyun.com/nas_team/nas-client-tools/raw/master/linux_client/check_noresvport.py -P /tmp/
    2. Run the following Python command to execute the script:
      python2.7 /tmp/check_noresvport.py -e
      If the "There is no issue for 'noresvport' on this ECS" message appears, skip the following steps.
  2. Fix issues related to the noresvport parameter.
    Note We recommend that you fix these issues during off-peak hours.
    Use one of the following mount scenario-specific solutions to fix the issues.
    • If you mount a NAS file system on an ECS instance, run the following command to execute the script again:
      python2.7 /tmp/check_noresvport.py -e -r
    • If you mount a NAS file system on a container, run the following command to execute the script again on the node where the container resides:
      python2.7 /tmp/check_noresvport.py -e -c
  3. Update the settings for an automatic mount.
    • If you configured an automatic mount, add the noresvport parameter to the settings for the automatic mount. For more information, see Automatically mount the NFS file system.
    • If no automatic mount is configured, skip this step.
    After the preceding steps are completed, repeat Step 1 and verify the result. If the issue persists, submit a ticket to contact Alibaba Cloud for technical support.

What happens when a network switchover or an HA switchover occurs on backend services?

NAS provides stable and continuous file storage services. However, network switchovers or HA switchovers of backend services may still occur in rare cases. HA switchovers of backend services may occur due to service upgrades. These switchovers can interrupt the client network. Before service upgrades, Alibaba Cloud sends notifications that include information about the upgrade schedule to all related users. This ensures that you have sufficient time to set the noresvport parameter. We recommend that you set the noresvport parameter at your earliest opportunity even if no upgrade is scheduled at the backend. This prevents failures that may occur on file systems due to other unexpected issues. These issues include changes on Server Load Balancer (SLB) instances, hardware failures at the backend, and other conditions that may trigger switchovers.

Why do I need to remount a file system? Can I use an alternative solution?

Before you can use the noresvport parameter to mount a file system, you must remount the file system. This way, you can end all TCP connections to which the noresvport parameter is not applied. When you use the noresvport parameter to mount the file system, new TCP connections are established. To end all previous TCP connections, you must stop all services that use the NAS file system. Then, you can run the umount command to unmount the file system.

If you do not want to remount the file system, we recommend that you create a mount target based on a new file system. In this case, you must mount the new file system on a different local directory. You can migrate all services to the new local directory. Then, you can disable the old mount directory and mount target.

How are files prefixed with .nfs generated? How do I delete files prefixed with .nfs?

If you delete a file when the file is being used by an application, a temporary file prefixed with .nfs is generated. When the process that uses the file ends, the temporary file is automatically deleted.

When I access a file in the directory of a NAS file system, the bind conn to session failed on NFSv4 server error message is returned. How do I fix this issue?

  • Cause

    The error message is returned because you mounted the file system by using the NFSv4.1 protocol. NAS does not support this protocol.

  • Solution

    Use the NFSv3.0 or NFSv4.0 protocol to remount the file system based on your business requirements. For more information, see Usage notes.