This is an old revision of the document!
Table of Contents
Attaching to NFS Server from Windows
Microsoft Windows can attach to NFS Shares with no problem, though you must use the command line to do it. You also need to install the NFS Client Role (Server) or package (Workstation) as it is not normally turned on. Note: everything other than the basic read-only mount requires rebooting the server. This must be done for it to work (because it is Microsoft, and . . . )
Read-only access
Attaching is fairly simple, if all you need is Read-Only access. Most web search results only show that. The following would mount \\192.168.1.5\storage\nfs on the n: drive, but with read only access.
mount \\192.168.1.5\storage\nfs n:
Read/Write Access as anon
To get read/write access, you will need to go a step further. If you do not care about mapping Windows users to users on your NFS server, you can just go in as the anonymous user (anon). Note that this will kill all restrictions. Anyone who can connect can read/write/delete any file in the target.
First, you will need to set the anonymous user to have the UID and GID (User ID and Group ID) of the owner of the NFS Server. In many Unix cases under NFSv3, this is root, with a UID and GID of 0. The following PowerShell script will set that. It will require a reboot after the registry keys have been added.
- anonymous.ps
# Powershell, set anonymous user to owner of nfs shares. Change the -Value to the UID/GID of the Unix user who owns the NFS share New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousUID -Value 0 -PropertyType "DWord" New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousGID -Value 0 -PropertyType "DWord" restart-computer --force
After reboot, you can mount the share as the anonymous user with full read/write access. However, remember, everyone can access it the same way.
# mount drive mount -o anon nolock \\192.168.1.5\storage\nfs n:
User Mapping
If you want to go to the next step, run regedit and find the following keys and delete them.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default\AnonymousUID Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default\AnonymousGID
Then, restart the machine
restart-computer --force
Create two files, passwd and group, in c:\windows\system32\drivers\etc. These files will map the local Windows user to the remote Unix user. Using this, you can create a unix user, give them ownership of the NFS Share, then, mapping a local Windows user to that remote Unix one, get some semblance of control.
This file maps a remote Unix user to the a local Windows user.
- passwd
# Place in c:\windows\system32\drivers\etc\passwd # domain\unixuser:x:unixUID:UnigGID:description:c:\Users\WinUser rodolico:x:1000:100:Rod,,,:c:\users\rodolico cait:x:1001:100:Cait,,,:c:\users\cait
- group
# place in c:\windows\system32\drivers\etc\group #group:pass:gid:uid wheel:x:0:0 users:x:100:100