If you want to share data across operating systems, you can mount a General-purpose Network File System (NFS) file system on a Windows Elastic Compute Service (ECS) instance. This way, you can upload data to and download data from the NFS file system. This topic describes how to mount an NFS file system on an ECS instance that resides in a virtual private cloud (VPC). In this example, Windows Server 2012 R2 is used.
Prerequisites
- A Windows ECS instance is available in the region where you create a file system. For more information, see Creation method overview.
- A General-purpose NAS file system of the NFS type 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.
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.
- Open a Command Prompt window and run the
mount
command.The following command output indicates that the NFS client is installed.
Step 2: Mount an NFS file system
You can manually mount a file system or enable automatic mounting for the file system. When you restart the ECS instance on which a file system is mounted, the mount information of the file system may be lost. To prevent this issue, you can manually mount a General-purpose NFS file system and then enable automatic mounting for 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 namefile-system-id.region.nas.aliyuncs.com
with the actual drive letter and domain name. For more information, see View the endpoint of a mount target.Note If 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 resolve theinvalid device
error that is returned when I try to rename a file on the 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.
Automatically mount the NFS file system
- 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.
FAQ
How can I resolve the file handle error
when I mount a file system?
- Cause
The Locking registry may not exist on the system, or the Locking registry exists but the value of Locking is not 1.
- Solution
- Open the Command Prompt, run the
regedit
command to open the Registry Editor window. - Choose , right-click a blank area, and then choose .
- Change the registry name to Locking and double-click Locking. In the Edit DWORD (32-bit) Value window, change the numeric value to 1.
- Click OK.
- Restart the ECS instance.
- Run the following command to remount 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 namefile-system-id.region.nas.aliyuncs.com
with the actual drive letter and domain name. - Run the
mount
command to check whether the mount is successful.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.
- Open the Command Prompt, run the
What can I do if I do not have the permissions to access a file system?
You can perform the following steps to configure the AnonymousGID and AnonymousUID registry keys:
- Log on to the ECS instance on which the file system is mounted.
- Open the Command Prompt, run the
regedit
command to open the Registry Editor window. - Choose .
- Right-click a blank area, choose , and then create the following registry keys:
- AnonymousGID: Set the value of the key to 0.
- AnonymousUID: Set the value of the key to 0.
- Restart the ECS instance.
- Run the following command to remount 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 namefile-system-id.region.nas.aliyuncs.com
with the actual drive letter and domain name. - Run the
mount
command to check whether the mount is successful.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.