Windows operating systems are less compatible with the Network File System (NFS) protocol. We recommend that you use Windows operating systems to mount NFS file systems only when you need to share data across operating systems. This topic describes how to mount an NFS file system on a Windows Elastic Compute Service (ECS) instance and perform read and write operations in the file system.
Prerequisites
A General-purpose NAS file system whose protocol type is NFS is created and the mount target of the file system is obtained. For more information, see Create a General-purpose NAS file system in the NAS console.
A Windows ECS instance is available in the region where you create the file system. For more information, see Creation method overview.
You cannot mount an Extreme NFS file system on Windows.
Step 1: Install an NFS client
Connect to the ECS instance. For more information, see Connection methods.
Start Server Manager.
Choose .
Follow the Add Roles and Features Wizard to install the NFS client.
In the Server Roles step, choose
and select Server for NFS.In the Features step, select Client for NFS.
Restart the ECS instance.
Start the Command Prompt and run the
mount
command.The following command output indicates that the NFS client is installed.
Step 2: Mount the General-purpose NFS file system
General-purpose NFS file systems can be manually or automatically mounted on ECS instances. Manual mounting is suitable for temporary mounting. If you manually mount a NAS file system on an ECS instance, you must remount the file system every time the ECS instance is started or restarted. Automatic mounting is suitable for persistent mounting. If you enable automatic mounting for a NAS file system, you do not need to remount the file system every time the ECS instance is started or restarted. To prevent the mount information from being lost after the ECS instance is restarted, we recommend that you enable automatic mounting for a NAS file system after you manually mount the file system.
Manually mount the NFS file system
On a Windows client, run the following command to mount the NFS file system:
mount -o nolock -o mtype=hard -o timeout=60 \\file-system-id.region.nas.aliyuncs.com\! Z:
You must replace the drive letter
Z
and the domain name of the mount targetfile-system-id.region.nas.aliyuncs.com
with the actual drive letter and domain name. For more information, see View the domain name of a mount target.NoteIf you mount a subdirectory of a NAS file system, the mount may fail. We recommend that you do not mount a subdirectory of a NAS file system. For more information, see How do I fix the invalid device error that is returned when I attempt to rename a file on a Windows NFS client?
Run the
mount
command to check the mount result.If the command output is similar to the following information and contains mount = hard, locking = no, and timeout = <a value that is greater than or equal to 10>, the NFS file system is mounted. Otherwise, the NFS file system fails to be mounted.
To resolve a mount failure, run the
net use <Drive letter> /delete
command to unmount the file system and then mount the file system again based on the mount command provided in Step 1.Double-click the This PC icon to view the shared file system.
Create files and folders in the shared file system to check whether you can manage the shared file system.
(Optional) Automatically mount the NFS file system
You can configure the c:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\auto_mount.bat
file of a Windows ECS instance to automatically mount an NFS file system when the ECS instance is restarted.
Go to the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp directory, create a script file named nas_auto.bat, and then enter the following content in the file.
Example:
mount -o nolock -o mtype=hard -o timeout=60 \\file-system-id.region.nas.aliyuncs.com\! Z:
You must replace the drive letter
Z:
and the domain namefile-system-id.region.nas.aliyuncs.com
with the actual drive letter and domain name. For more information, see Mount parameters.Create a scheduled task.
Open the Control Panel and click System and Security. In the Administrative Tools section, click Schedule tasks.
In the Task Scheduler window, choose .
On the General tab, enter the name of the 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. Otherwise, the configurations of automatic mounting for an NFS file system do not take effect.
Click the Triggers tab. Click New Trigger. Select At log on from the Begin the task drop-down list. In the Advanced settings section, select Enabled. Click OK.
Click the Actions tab. Click New Action. Select Start a program from the Action drop-down list and then specify the nas_auto.bat file that you created in Step 1 in the Program/script field. 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 drop-down list under If the task is already running, then the following rule applies.
Click OK.
Restart the ECS instance to check whether the scheduled task is created.
ImportantIf you restart the ECS instance, services are interrupted. We recommend that you perform the operation during off-peak hours.
View the status of the scheduled task.
If an output that is similar to the following example appears, the scheduled task is created.
Run the
mount
command to check the mount result.If the command output is similar to the following information and contains mount=hard, locking=no, and timeout=<a value that is greater than or equal to 10>, the NFS file system is mounted. Otherwise, the NFS file system fails to be mounted.
To resolve a mount failure, open the nas_auto.bat script file and replace the existing script based on the content provided in Step 1.