Because Windows systems have limited compatibility with the NFS protocol, you should mount an NFS file system on a Windows system only when you need to share data across different operating systems. This topic describes how to mount an NFS file system on an Elastic Compute Service (ECS) instance that runs Windows.
Prerequisites
-
You have created a General-purpose NAS file system that uses the NFS protocol and obtained the mount target address of the file system. For more information, see Create a General-purpose NAS file system in the console.
-
An ECS instance that runs Windows is available in the same region as the file system. For more information, see Create an ECS instance.
-
The ECS instance and the mount target are in the same VPC.
Extreme NAS file systems cannot be mounted on Windows operating systems using the NFS protocol.
Step 1: Install the NFS client
Connect to the ECS instance. For more information, see Connect to an ECS instance.
-
Open Server Manager.
-
Choose .
-
You can follow the instructions in the Add Roles and Features Wizard to install the NFS client.
-
On the Server Roles page, go to and select Server for NFS.
-
On the Features page, select Client for NFS.
-
-
Restart the ECS instance.
-
Open Command Prompt and run the
mountcommand.If the following information is returned, the NFS client is installed.
C:\Users\Administrator>mount Local Remote Properties ------------------------------------------------------------------------------- --
Step 2: Mount the General-purpose NAS file system that uses the NFS protocol
You can mount a General-purpose NAS file system that uses the NFS protocol either manually or automatically. Manual mounts are temporary and must be re-established each time the server starts or restarts. Automatic mounts are persistent. To ensure the file system remains accessible after a server restart, we recommend that you configure an automatic mount after you successfully mount the file system manually.
Manually mount the General-purpose NAS file system that uses the NFS protocol
-
On the Windows client, run the following command to mount the General-purpose NAS file system that uses the NFS protocol.
mount -o nolock -o mtype=hard -o timeout=60 \\file-system-id.region.nas.aliyuncs.com\! Z:Replace the drive letter
Zand the mount target addressfile-system-id.region.nas.aliyuncs.comwith your actual values. For more information about mount target addresses, see Manage mount targets.Note-
Do not use a system drive letter, such as
C:, to mount the NAS file system. Instead, use a high-order drive letter, such asZ:orY:, as the mount target. -
Mounting a NAS subdirectory may fail. Avoid mounting NAS subdirectories. For more information, see How do I resolve the "invalid device" error that is returned when I rename a file in an NFS file system on a Windows client?.
-
-
Run the
mountcommand to check the mount status.After the mount is complete, verify that the returned information includes mount=hard, locking=no, and a timeout parameter >=10. If it does not, the mount operation has failed.
If the output is not as expected, run the
net use <drive letter> /deletecommand to unmount the file system. Then, remount the file system by following the instructions in Step 1.C:\Users\Administrator>mount Local Remote Properties Z: \\29xxx.nas~ UID=-2, GID=-2 rsize=1048576, wsize=1048576 mount=hard, timeout=10.0 retry=1, locking=no fileaccess=755, lang=GB2312-80 casesensitive=no sec=sys -
Double-click the This PC icon to view the new shared file system.
Create a folder and a file in the shared file system to verify that you can perform operations on the file system.
After the mount is complete, the mapped NAS network drive appears under Network locations in This PC.
(Optional) Automatically mount the General-purpose NAS file system that uses the NFS protocol
To automatically mount the NFS file system when the instance restarts, configure the c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\auto_mount.bat file on the Windows ECS instance.
-
In the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp directory of the Windows system, create a script file named nas_auto.bat and add the following content.
Example:
mount -o nolock -o mtype=hard -o timeout=60 \\file-system-id.region.nas.aliyuncs.com\! Z:Replace the drive letter
zand the mount target addressfile-system-id.region.nas.aliyuncs.comwith your actual values. For more information about mount parameters, see Mount parameters. -
Create a scheduled task.
-
Open Control Panel, click System and Security, and then under Administrative Tools, click Schedule Tasks.
-
On the Task Scheduler page, you can choose .
-
On the General tab, enter a Name for the scheduled task, and select Run whether user is logged on or not and Run with highest privileges.
ImportantIf you use Windows Server 2016, you must select Run only when user is logged on for the automatic mount configuration to take effect.
In the Security options section of the General tab, select Run whether user is logged on or not (W), select the Run with highest privileges (I) check box, and from the Configure for (C) drop-down list, select Windows Vista™, Windows Server™ 2008.
-
On the Triggers tab, click New. From the Begin the task list, select At log on. In the Advanced settings section, select Enabled and click OK.
-
On the Actions tab, click New, and select Start a program from the Action list. In the Program/script field, select the nas_auto.bat file that you created in Step 1 and click OK.
-
Click the Conditions tab. In the Network section, select Start only if the following network connection is available. Select Any connection from the drop-down list.
-
Click the Settings tab. Select If the running task does not end when requested, force it to stop. Select Do not start a new instance from the If the task is already running, then the following rule applies drop-down list.
-
Click OK.
-
Restart the ECS instance to validate the result.
ImportantRestarting the ECS instance interrupts services. Restart the instance during off-peak hours.
-
Check the status of the scheduled task
The scheduled task is running as expected if you see the following status in Task Scheduler: the status of the scheduled task named nas is Ready, the trigger is At log on of any user, and the last run result is The operation completed successfully. (0x0).
-
Run the
mountcommand to check the mount status.After the mount is complete, verify that the returned information includes mount=hard, locking=no, and a timeout parameter >=10. If it does not, the mount operation has failed.
If an issue occurs, open the nas_auto.bat script and replace its content with the script from Step 1.
-
-