This topic describes how to mount a Server Message Block (SMB) file system of Apsara File Storage NAS on a Windows Elastic Compute Service (ECS) instance. After you configure a Windows ECS instance, you can manually or automatically mount an SMB file system.

Prerequisites

The following operations are completed:

Configure a Windows ECS instance

Perform the following steps when you mount an SMB file system on a Windows ECS instance:

  1. Connect to the ECS instance. For more information, see Connect to ECS instances.
  2. For Windows 2016 or later, run the following command to allow anonymous access from clients:
    REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters /f /v AllowInsecureGuestAuth /t REG_DWORD /d 1
  3. Start the Workstation service.
    1. Open the Windows Start menu. ChooseAll Programs > Accessories > Run or press Win+R, and enter services.msc to open the Services window.
    2. Make sure that the Workstation service is in the Started state and the startup type is Automatic.

      By default, the Workstation service is in the Started state.

      Workstation
  4. Start the TCP/IP NetBIOS Helper service.
    1. Open the Network and Sharing Center window, and click the active network connection.
    2. Select Properties. In the Connection Properties dialog box, double-click Internet Protocol Version 4 (TCP/IPv4). In the Internet Protocol Version 4 (TCP/IPv4) Properties dialog box, click Advanced.
    3. In the Advanced TCP/IP Settings dialog box, choose WINS > Enable NetBIOS over TCP/IP.Enable the NetBIOS over TCP/IP service
    4. Open the Windows Start menu, choose All Programs > Accessories > Run or press Win+R, and enter services.msc to open the Services window.
    5. Make sure that the TCP/IP NetBIOS Helper service is in the Started state and the startup type is Automatic.

      By default, the TCP/IP NetBIOS Helper service is in the Started state.

      TCP/IP NetBIOS Helpe

Manually mount an SMB file system

  1. Run the mount command to mount an SMB file system.
    Open the command prompt and run the following command to mount an SMB file system:
    net use Z: \\file-system-id.region.nas.aliyuncs.com\myshare

    Command syntax: net use <Letter of the destination drive> \\<Domain name of the mount target>\myshare.

    • Letter of the destination drive: the letter of the drive on which you mount an SMB file system. Replace this parameter with the letter of the actual destination drive.
      Note The letter of the destination drive must be different from the existing drive letters.
    • Domain name of the mount target: The domain name of the mount target is automatically generated when the mount target is created. Replace this parameter with the actual domain name of the mount target. To obtain the domain name of the mount target, perform the following steps: Log on to the NAS console, find the file system, and then click Management. On the details page that appears, the domain name of the mount target is displayed.
    • myshare: the name of an SMB share. You cannot change the name.
    Note For Windows 2019 or later, we recommend that you use the Powershell command New-SmbGlobalMapping to mount the SMB file system. Run the following command to mount the SMB file system:

    New-SmbGlobalMapping -LocalPath z: -RemotePath \\file-system-id.region.nas.aliyuncs.com\myshare -Persistent $true

    If an AD domain controller is installed on the ECS instance, you must pass the identity verification when you run the command. You can enter a valid identity in the AD domain.

  2. Confirm that the SMB file system is mounted.
    Run the net use command to check the mount result.

    The command output in the following figure indicates a successful mount.

    View the mount resultAfter the SMB file system is mounted, you can read data from and write data to the NAS file systems on the ECS instance.

Automatically mount an SMB file system

Before you configure automatic mounting, make sure that the preceding manual mounting is successful.

Note In Windows operating systems, most system calls including Services and Scheduled Tasks are performed by using the SYSTEM account. However, the following mount process is performed by using a logon user account. If you need to mount an SMB file system by using the SYSTEM account, see https://yq.aliyun.com/articles/715687?spm=a2c4e.11155435.0.0.3ef53dadEXBsZs.
  1. Open the command prompt and run the following command to configure the auto_mount.bat script:
    echo %HOMEPATH%\mount.bat > auto_mount.bat
  2. Run the following three commands to enable the auto_mount.bat script to automatically run after user logon and grant the read and execute permissions to other users:
    MOVE auto_mount.bat "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\auto_mount.bat"

    icacls "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\auto_mount.bat" /grant everyone:rx

    REG ADD HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run /f /v MyMount /t REG_SZ /d "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\auto_mount.bat"

  3. Run the following command to configure the mount.bat script:
    echo net use z: \\file-system-id.region.nas.aliyuncs.com\myshare > "%HOMEPATH%\mount.bat"

    Replace file-system-id.region.nas.aliyuncs.com with the actual domain name of the mount target.

    Note If the SMB file system supports ADs and ACLs, you can run the following command to configure the script. Then, you can mount the SMB file system as a domain user rather than a Windows logon user:

    echo net use z: \\file-system-id.region.nas.aliyuncs.com\myshare /user:user@domain password > "%HOMEPATH%\mount.bat"

    Replace file-system-id.region.nas.aliyuncs.com with the actual domain name of the mount target, replaceuser@domain with the actual domain username, and replace password with the actual domain user password.

  4. Restart the ECS instance.
    Run the net use command to check the mount result.