Mount an SMB file system

更新时间:
复制 MD 格式

Mount a NAS file system that supports the SMB protocol on a Windows ECS instance to share files across the network.

Prerequisites

  • An ECS instance running Windows is created. Create an ECS instance.

  • A General-purpose NAS file system using the SMB protocol is created in the same region and VPC as the ECS instance, and you have the mount target address. Create a General-purpose NAS file system in the console.

  • Network connectivity is established.

    • For classic network mounts, the ECS instance and NAS file system must belong to the same Alibaba Cloud account.

    • The permission group for the file system grants access to the Windows ECS instance.

    • TCP port 445 is open (required by SMB).

      If port 445 is closed, Add a security group rule to allow traffic on this port.

Step 1: Prepare the environment

Complete these steps once per Windows server before the first mount.

Note
  1. Connect to the ECS instance.

  2. Allow insecure guest logons for the following OS versions.

    1. For Windows Server 2016 and later, run the following command.

      REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters /f /v AllowInsecureGuestAuth /t REG_DWORD /d 1
    2. For Windows Server 2025, you also need to disable SMB signing. You can use one of the following methods:

      • Method 1: Use Group Policy (GUI)

        1. Press Win+R, enter gpedit.msc, and press Enter to open the Local Group Policy Editor.

        2. Navigate to . Double-click Microsoft network client: Digitally sign communications (always), select Disabled, and then click OK.image

      • Method 2: Use the registry

        If Group Policy is unavailable, disable SMB signing through the registry:

        Registry editor

        1. Press Win+R, enter regedit, and press Enter to open the Registry Editor.

        2. Navigate to the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters.

        3. Find the RequireSecuritySignature entry and set its value to 0.

        4. Restart the computer for the change to take effect.

        CLI

        1. Open Command Prompt as an administrator and run the following command:

          reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" /v RequireSecuritySignature /t REG_DWORD /d 0 /f
        2. Restart the computer for the change to take effect.

  3. Enable the Workstation service.

    1. Navigate to , or press Win+R. In the Run dialog box, enter services.msc, and press Enter to open the Services console.

    2. In the list of services, find Workstation. Verify that its status is Running and its startup type is Automatic.

      By default, the Workstation service is running.

      Workstation

  4. Enable the TCP/IP NetBIOS Helper service.

    1. Open the Network and Sharing Center and click the active network connection.

    2. Click Properties, double-click Internet Protocol Version 4 (TCP/IPv4), and then click Advanced.

    3. In the Advanced TCP/IP Settings dialog box, go to the tab and select Enable NetBIOS over TCP/IP.Enable NetBIOS over TCP/IP

    4. Navigate to , or press Win+R. In the Run dialog box, enter services.msc, and press Enter to open the Services console.

    5. In the list of services, find TCP/IP NetBIOS Helper. Verify that its status is Running and its startup type is Automatic.

      By default, the TCP/IP NetBIOS Helper service is running.

      TCP/IP NetBIOS Helpe

Step 2: Mount the NAS SMB file system

You can mount an SMB file system manually or automatically. A manual mount does not persist across restarts. After verifying a manual mount, configure an automatic mount for persistence.

Manual mount

Mount the NAS SMB file system to your Windows ECS instance using the mount target address.

  1. Connect to the ECS instance.

  2. Open a Command Prompt window and run the following command to mount the SMB file system.

    net use Z: \\file-system-id.region.nas.aliyuncs.com\myshare

    Parameter

    Description

    Z

    Drive letter for the mapped file system. Use another letter if Z: is taken.

    file-system-id.region.nas.aliyuncs.com

    Mount target address generated when you created the SMB file system. Replace with your actual address.

    In the NAS console, click the target file system, and then click Mount Targets. Hover over the Mount target icon in the Mount Target Address column to obtain the address.

    myshare

    The SMB share name. Do not change this name.

    For Windows Server 2019 and later, use the New-SmbGlobalMapping PowerShell cmdlet to make the mount point accessible to all users:

    If prompted for credentials, enter valid workgroup credentials. For example, use workgroup\administrator with the ECS administrator password.

    • Mount command

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

      Remove-SmbGlobalMapping -LocalPath z:
    • Verification command

      Get-SmbGlobalMapping
  3. Verify that the NAS SMB file system is mounted.

    • Run the following command:

      net use
    • Example output

      Output similar to the following indicates a successful mount:

      Mount result

    If the mount fails, use Use a script for automatic troubleshooting to diagnose the issue, or check FAQ about mounting and access for common error solutions.

(Optional) Automatic mount

Create a startup script at c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\auto_mount.bat to auto-mount the SMB file system on restart.

  1. To create the auto_mount.bat script, open a Command Prompt window and run the following command.

    echo %HOMEPATH%\mount.bat > auto_mount.bat
  2. Run the following three commands to move the script to the startup folder, grant the required permissions, and add a registry entry to run the script at logon.

    MOVE auto_mount.bat "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp"
    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. To configure the mount.bat script, run the following command.

    Mount without authentication

    For scenarios that do not require authentication, use the following command:

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

    Mount with authentication

    If your SMB file system uses an AD domain and ACLs, run the following command to mount the file system with specific domain credentials.

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

    Replace the drive letter z, mount target address file-system-id.region.nas.aliyuncs.com, AD domain username user@domain, and domain user password password with your actual values.

  4. Restart the ECS instance.

    After the instance restarts and you log back in, run the net use command to verify the mount.

    Important

    Restarting an ECS instance interrupts services. Perform this during off-peak hours.

Next steps