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.

Configure a Windows ECS instance

The first time you mount an SMB file system on a Windows ECS instance, perform the following steps:

  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. Enable the Workstation service.
    1. Open the Windows Start menu. Choose All Programs > Accessories > Run or press Win+R. Then, 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. Enable the TCP/IP NetBIOS Helper service.
    1. On the Network and Sharing Center page, 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 NetBIOS over TCP/IP
    4. Open the Windows Start menu. Choose All Programs > Accessories > Run or press Win+R. Then, 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 a 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 want to mount an SMB file system. Replace the value of the parameter with the letter of an 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 you create the mount target. Replace the value of the parameter with the domain name of an actual 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 that you want to manage, and then click Manage. On the details page that appears, the domain name of the mount target is displayed.
    • myshare: the name of the shared SMB directory. You cannot change the name.
    Note For Windows 2019 or later, we recommend that you run the New-SmbGlobalMapping command in Powershell 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 you are prompted to enter an identity when you run the preceding command, you can enter a valid identity in a workgroup, for example, workgroup\administrator.

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

    If the output that is similar to the following information appears, the mount is successful.

    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 can configure automatic mounting, make sure that the preceding manual mounting is successful.

  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 commands to enable the auto_mount.bat script to automatically run after user logon, and then grant the read and execute permissions to everyone:
    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 domain name of an actual mount target.

    Note If the SMB file system supports Active Directory (AD) and access control lists (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.