If you want to share data across operating systems, you can mount a Network File System (NFS) file system on a Windows Edge Node Service (ENS) 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 a Windows ENS instance.
Prerequisites
A Windows ENS instance is available on the edge node on which you create an File Storage NAS file system.
A NAS file system is created and the URL of the mount target of the NAS file system is obtained. The NAS file system and the ENS instance reside in the same virtual private cloud (VPC).
Procedure
Connect to the ENS instance.
Install an NFS client.
Start Server Manager.
Choose Manage > Add Roles and Features.
Follow the Add Roles and Features wizard to install the NFS client.
In the Server Roles step, choose File and Storage Services > File and iSCSI Services and select Server for NFS.
In the Features step, select Client for NFS.
Restart the ENS instance.
Open a Command Prompt window and run the mount command. The following command output indicates that the NFS client is installed.

Modify the registry by adding the default user ID (UID) and group ID (GID) that are used for anonymous users to access the NAS file system. This prevents the issue that you do not have the permissions to open files in the NAS file system after you mount the NAS file system.
In the Registry Editor window, choose HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > ClientForNFS > CurrentVersion > Users > Default > Mount. Right-click a blank area, choose New > DWORD (32-bit) Value, and then create the Locking, AnonymousGID, and AnonymousUID registry keys. You must set the value of the Locking registry key to 1.
In the Registry Editor window, choose HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > ClientForNFS > CurrentVersion > Default. Right-click a blank area, choose New > DWORD (32-bit) Value, and then create the AnonymousGID and AnonymousUID registry keys.
Restart the system.
You must restart the system. Otherwise, you have only the read permissions on the NAS file system after you mount the NAS file system.
Add a route.
Before you access the NAS mount target, you must run a command in the following format to add a route for the Windows ENS instance:
route add 100.64.XXX.XXX Private IP address of the instance.Mount the NFS file system.
On the Windows client, run a command in the following format to mount the NFS file system:
mount Mount target path <Drive letter>.NoteWindows clients support only NFSv3.
You can obtain the mount point URL for NFSv3 on the details page of the NFS file system. For example, if the mount point URL for NFSv3 on the details page is
100.64.XXX.XXX:/source_path, the mount point URL for Windows clients is\\100.64.XXX.XXX\source_path.Verify the mount result.
Double-click the This PC icon to view the shared file system.
Mount a NAS file system by using a script
Script capabilities
Installs an NFS client.
Modifies the registry.
Configures the read and write permissions on the NFS file system.
Enables automatic mount on startup.
The script does not contain restart commands. After an NFS client is installed for the first time on a Windows ENS instance or the registry is modified, you must manually restart the ENS instance. Otherwise, you have only the read permissions on the directory to which the NFS file system is mounted.
Usage methods
Store the script in the specified directory such as a directory of drive C and name the script nfs_mount.ps1.
Run the script in PowerShell.
Method 1:
powershell -file C:\nfs_mount.ps1Method 2:
powershell -file C:\nfs_mount.ps1 -Mount target URL -drive z # If you use this method, the default URL of the mount target and drive letter in the script are overwritten.
Configure the read and write permissions on the NFS file system
[CmdletBinding()]
Param(
The URL of the mount target.
[string]$url="100.125.255.100\nas_test",
# The drive letter.
[string]$drive="z"
)
# Query the current execution time.
$now = Get-Date
# Specify the current execution directory as the log file path.
$logPath="C:\"
# Specify the log file name.
$logName = "executLog"
$logFileName= $logName + "_" + $now.ToString("yyyy-MM-dd")+".log"
$logInfo = $now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " "
# Configure the full path of the log file.
$logPathFile = Join-Path $logPath $logFileName
Write-Output ($logInfo + "Mount target path:"+$url + "Drive letter:"+$drive)
Write-Output ($logInfo + "Mount target path:"+$url + "Drive letter:"+$drive) | Out-File -FilePath $logPathFile -Encoding default -Append
$nfs=get-WindowsFeature -Name "NFS-Client"
if($nfs.installed){
$nas_start = (Get-Item HKCU:\Software\Microsoft\Windows\CurrentVersion\Run).GetValueNames().Contains("nas_run")
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start)
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start) | Out-File -FilePath $logPathFile -Encoding default -Append
if(!$nas_start){
Write-Output ($logInfo +": Enable automatic mount on startup")
Write-Output ($logInfo +": Enable automatic mount on startup") | Out-File -FilePath $logPathFile -Encoding default -Append
$nas_script_path = $myinvocation.mycommand.definition
$run_script = "powershell -file "+ $nas_script_path +" -url "+ $url +" -drive "+ $drive
$nas_run = "nas_run"
$nas_run_result = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name $nas_run -PropertyType String -Value $run_script -ErrorAction Continue -ErrorVariable run_err_msg
if($err_msg){
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg)
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result)
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
Write-Output ($logInfo + "The NFS client is installed and an NFS mount target is available.")
Write-Output ($logInfo + "The NFS client is installed and an NFS mount target is available.") | Out-File -FilePath $logPathFile -Encoding default -Append
$nfs_url = "mount -o nolock -o mtype=hard -o timeout=60 \\$url ${drive}:"
Write-Output ($logInfo + ": Mount the NAS file system. "+$nfs_url)
Write-Output ($logInfo + ": Mount the NAS file system. " +$nfs_url) | Out-File -FilePath $logPathFile -Encoding default -Append
$reslut = cmd /c $nfs_url
Write-Output ($logInfo+$reslut)
Write-Output ($logInfo+$reslut) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo +": No NFS client is installed. Install an NFS client, modify the registry, and then restart the system.")
Write-Output ($logInfo +": No NFS client is installed. Install an NFS client, modify the registry, and then restart the system.") | Out-File -FilePath $logPathFile -Encoding default -Append
Add-WindowsFeature -Name "NFS-Client"
$lock_path = Test-Path HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount
if($lock_path){
$lock = (Get-Item HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount).GetValueNames().Contains("Locking")
if(!$lock){
$lock_result = New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount" -Name "Locking" -PropertyType DWord -Value 1 -ErrorAction Continue -ErrorVariable err_msg
if($err_msg){
Write-Output ($logInfo + "The registry fails to be modified:" +$err_msg)
Write-Output ($logInfo + "The registry fails to be modified:" +$err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "The registry modification result:" +$lock_result)
Write-Output ($logInfo + "The registry modification result:" +$lock_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
}else{
Write-Output "The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount does not exist. Create it."
Write-Output "The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount does not exist. Create it." | Out-File -FilePath $logPathFile -Encoding default -Append
}
$id_path = Test-Path HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
if ($id_path){
$gid = (Get-Item HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default).GetValueNames().Contains("AnonymousGID")
$uid = (Get-Item HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default).GetValueNames().Contains("AnonymousUID")
if (!$gid){
$gid_result = New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousGID" -PropertyType DWord -Value 0 -ErrorAction Continue -ErrorVariable gid_err_msg
if($gid_err_msg){
Write-Output ($logInfo + "The registry fails to be modified:" +$gid_err_msg)
Write-Output ($logInfo + "The registry fails to be modified:" +$gid_err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "The registry modification result:" +$gid_result)
Write-Output ($logInfo + "The registry modification result:" +$gid_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
if (!$uid){
$uid_result = New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousUID" -PropertyType DWord -Value 0 -ErrorAction Continue -ErrorVariable uid_err_msg
if($uid_err_msg){
Write-Output ($logInfo + "The registry fails to be modified:" +$uid_err_msg)
Write-Output ($logInfo + "The registry fails to be modified:" +$uid_err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "The registry modification result:" +$uid_result)
Write-Output ($logInfo + "The registry modification result:" +$uid_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
}else{
Write-Output ($logInfo + "The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default does not exist. Create it.")
Write-Output ($logInfo + "The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default does not exist. Create it.") | Out-File -FilePath $logPathFile -Encoding default -Append
}
$nas_start = (Get-Item HKCU:\Software\Microsoft\Windows\CurrentVersion\Run).GetValueNames().Contains("nas_run")
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start)
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start) | Out-File -FilePath $logPathFile -Encoding default -Append
if(!$nas_start){
Write-Output ($logInfo +": Enable automatic mount on startup")
Write-Output ($logInfo +": Enable automatic mount on startup") | Out-File -FilePath $logPathFile -Encoding default -Append
$nas_script_path = $myinvocation.mycommand.definition
$run_script = "powershell -file "+ $nas_script_path +" -url "+ $url +" -drive "+ $drive
$nas_run = "nas_run"
$nas_run_result = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name $nas_run -PropertyType String -Value $run_script -ErrorAction Continue -ErrorVariable run_err_msg
if($err_msg){
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg)
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result)
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
$nfs_url = "mount -o nolock -o mtype=hard -o timeout=60 \\$url ${drive}:"
Write-Output ($logInfo + ": Mount the NAS file system. "+$nfs_url)
Write-Output ($logInfo + ": Mount the NAS file system. " +$nfs_url) | Out-File -FilePath $logPathFile -Encoding default -Append
$result = cmd /c $nfs_url
Write-Output ($logInfo +": The NAS file system is mounted." +$result)
Write-Output ($logInfo +": The NAS file system is mounted." +$result) | Out-File -FilePath $logPathFile -Encoding default -Append
Write-Output ($logInfo +": The configuration is complete.")
Write-Output ($logInfo +": The configuration is complete.") | Out-File -FilePath $logPathFile -Encoding default -Append
}
Configure the read-only permissions on the NFS file system and enable automatic mount on startup
[CmdletBinding()]
Param(
The URL of the mount target.
[string]$url="100.125.255.100\nas_test",
# The drive letter.
[string]$drive="z"
)
# Query the current execution time.
$now = Get-Date
# Specify the current execution directory as the log file path.
$logPath="C:\"
# Specify the log file name.
$logName = "executLog"
$logFileName= $logName + "_" + $now.ToString("yyyy-MM-dd")+".log"
$logInfo = $now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " "
# Configure the full path of the log file.
$logPathFile = Join-Path $logPath $logFileName
Write-Output ($logInfo + "Mount target path:"+$url + "Drive letter:"+$drive)
Write-Output ($logInfo + "Mount target path:"+$url + "Drive letter:"+$drive) | Out-File -FilePath $logPathFile -Encoding default -Append
$nfs=get-WindowsFeature -Name "NFS-Client"
if($nfs.installed){
$nas_start = (Get-Item HKCU:\Software\Microsoft\Windows\CurrentVersion\Run).GetValueNames().Contains("nas_run")
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start)
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start) | Out-File -FilePath $logPathFile -Encoding default -Append
if(!$nas_start){
Write-Output ($logInfo +": Enable automatic mount on startup")
Write-Output ($logInfo +": Enable automatic mount on startup") | Out-File -FilePath $logPathFile -Encoding default -Append
$nas_script_path = $myinvocation.mycommand.definition
$run_script = "powershell -file "+ $nas_script_path +" -url "+ $url +" -drive "+ $drive
$nas_run = "nas_run"
$nas_run_result = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name $nas_run -PropertyType String -Value $run_script -ErrorAction Continue -ErrorVariable run_err_msg
if($err_msg){
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg)
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result)
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
Write-Output ($logInfo + "The NFS client is installed and an NFS mount target is available.")
Write-Output ($logInfo + "The NFS client is installed and an NFS mount target is available.") | Out-File -FilePath $logPathFile -Encoding default -Append
$nfs_url = "mount -o nolock -o mtype=hard -o timeout=60 \\$url ${drive}:"
Write-Output ($logInfo + ": Mount the NAS file system. "+$nfs_url)
Write-Output ($logInfo + ": Mount the NAS file system. " +$nfs_url) | Out-File -FilePath $logPathFile -Encoding default -Append
$reslut = cmd /c $nfs_url
Write-Output ($logInfo+$reslut)
Write-Output ($logInfo+$reslut) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo +": No NFS client is installed. Install an NFS client, modify the registry, and then restart the system.")
Write-Output ($logInfo +": No NFS client is installed. Install an NFS client, modify the registry, and then restart the system.") | Out-File -FilePath $logPathFile -Encoding default -Append
Add-WindowsFeature -Name "NFS-Client"
$lock_path = Test-Path HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount
if($lock_path){
$lock = (Get-Item HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount).GetValueNames().Contains("Locking")
if(!$lock){
$lock_result = New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount" -Name "Locking" -PropertyType DWord -Value 1 -ErrorAction Continue -ErrorVariable err_msg
if($err_msg){
Write-Output ($logInfo + "The registry fails to be modified:" +$err_msg)
Write-Output ($logInfo + "The registry fails to be modified:" +$err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "The registry modification result:" +$lock_result)
Write-Output ($logInfo + "The registry modification result:" +$lock_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
}else{
Write-Output "The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount does not exist. Create it."
Write-Output "The registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Users\Default\Mount does not exist. Create it." | Out-File -FilePath $logPathFile -Encoding default -Append
}
$nas_start = (Get-Item HKCU:\Software\Microsoft\Windows\CurrentVersion\Run).GetValueNames().Contains("nas_run")
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start)
Write-Output ($logInfo +": Automatic mount on startup>>"+$nas_start) | Out-File -FilePath $logPathFile -Encoding default -Append
if(!$nas_start){
Write-Output ($logInfo +": Enable automatic mount on startup")
Write-Output ($logInfo +": Enable automatic mount on startup") | Out-File -FilePath $logPathFile -Encoding default -Append
$nas_script_path = $myinvocation.mycommand.definition
$run_script = "powershell -file "+ $nas_script_path +" -url "+ $url +" -drive "+ $drive
$nas_run = "nas_run"
$nas_run_result = New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name $nas_run -PropertyType String -Value $run_script -ErrorAction Continue -ErrorVariable run_err_msg
if($err_msg){
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg)
Write-Output ($logInfo + "Automatic mount on startup fails to be enabled:" +$run_err_msg) | Out-File -FilePath $logPathFile -Encoding default -Append
}else{
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result)
Write-Output ($logInfo + "Automatic mount on startup is enabled:" +$nas_run_result) | Out-File -FilePath $logPathFile -Encoding default -Append
}
}
$nfs_url = "mount -o nolock -o mtype=hard -o timeout=60 \\$url ${drive}:"
Write-Output ($logInfo +": Mount the NAS file system. "+$nfs_url)
Write-Output ($logInfo +": Mount the NAS file system. " +$nfs_url) | Out-File -FilePath $logPathFile -Encoding default -Append
$result = cmd /c $nfs_url
Write-Output ($logInfo +": The NAS file system is mounted." +$result)
Write-Output ($logInfo +": The NAS file system is mounted." +$result) | Out-File -FilePath $logPathFile -Encoding default -Append
Write-Output ($logInfo +": The configuration is complete.")
Write-Output ($logInfo +": The configuration is complete.") | Out-File -FilePath $logPathFile -Encoding default -Append
}