Configuring NFS Services for Windows
To export the root filesystem via NFS on Windows, you must create a mapping file and then tell NFS which filesystem it should export. The NFS server provided with Cygwin includes a script that will do this correctly for Windows 2000, Windows NT, and Windows XP. TimeSys strongly recommends using this script.
Using the NFS Server Script
If you have installed a Cygwin distribution (version cygwin-1.5.14 or newer) from TimeSys, or if you have installed nfs-server-2.3-3 or newer, use the nfs-server-config script to set up a default configuration for running an NFS server on Windows. As part of this setup, the script will do the following:
- Optionally, create a user account under which to run the services.
- Install portmap, mountd, and nfsd as Windows services.
- Create a sample /etc/exports file.
- Create a sample mapping file.
You can then edit the /etc/exports file and the mapping file for your own system, and can restart the services from the Windows Control Panel.
The script is located in /bin/. The /usr/share/doc/Cygwin/nfs-server-2.3-*.README file in your Cygwin installation directory contains notes on installation, and documents known problems and workarounds with the NFS server.
Depending on which version of Windows you are running, you can choose to install the NFS services so that they run under the local system account, or under a separate user account.
- For Windows 2000 and Windows NT, you may run nfsd under either a local system account or a separate user account. In general, you probably want to run under the local system account.
- For Windows XP, you must run nfsd under a separate user account.
If you choose to run nfsd under a separate user account, you will be prompted for a user name and password. If the user name that you supply does not exist, it will be created.
Example of Using the Script
In the example below, user input is in bold.
TimeSys Cygwin distribution - version 1.5a build 13 Current cygwin DLL version is 1.5.17(0.129/4/2) $ /bin/nfs-server-config This script sets up a default configuration for running an NFS server under Cygwin. As part of this setup, the script will do the following: 1) Create a user account to run the services under [OPTIONAL] 2) Install portmap, mountd, and nfsd as Windows services 3) Create a sample exports file 4) Create a sample uid/gid mapping file. After installing, please read the nfs-server README for Cygwin: /usr/share/doc/Cygwin/nfs-server-2.3-*.README This document contains notes on installation and documents known problems and workarounds with the NFS server, ex: Do you want to continue? (yes/no) yes You can choose to install the services so that they run under the local system account, or under a separate user account. Which option you should choose depends on which version of Windows you are running: Windows 2000 : You may run nfsd under either a local system account or a separate user account. You _probably_ want to run under the local system account. Windows XP : You _must_ run nfsd under a separate user account. If you choose to run nfsd under a separate user account, you will be prompted for an user name and password. If the user name you supply does not exist, it will be created. Do you want to run nfsd under a separate user account? (yes/no) yes User name : nfs_admin Password : fsd User nfs_admin already exists Assigning required privileges to user nfs_admin Adding user nfs_admin to /etc/passwd A service named "portmap" already exists on this machine. Do you want to re-install the portmap service? (yes/no) yes Stopping portmap service... Uninstalling portmap service... Installing portmap service... A service named "mountd" already exists on this machine. Do you want to re-install the mountd service? (yes/no) yes Stopping mountd service... Uninstalling mountd service... Installing mountd service... A service named "nfsd" already exists on this machine. Do you want to re-install the nfsd service? (yes/no) yes Stopping nfsd service... Uninstalling nfsd service... Installing nfsd service... juser@timesys /cygdrive/c/Cygwin/bin $
Creating the /etc/exports File
The /etc/exports file determines which host directories are made accessible (exported) to which target systems. Refer to Exporting a Root Filesystem via NFS for more information.
Creating the NFS Mapping File
The mapping file defines aliases for remote users, which sets their access privileges. It is required when exporting via NFS on Windows. You can choose the file name; however, using the extension .map to identify the file is recommended for convenience.
If you use a Windows-provided editor to create text files, they might contain DOS-style line breaks. Use the dos2unix utility in Cygwin to convert the files for use in a UNIX-style system. Issue the command dos2unix --help for details about this utility.
You will use this mapping file in the /etc/exports file when you specify the permissions for the exported RFS directory. Use a text editor to edit the mapping file server.map in the /etc/nfs directory and create the entries shown in the following listing. These entries should match the actual Cygwin UID and GID of the person who installed the RFS. They might differ from the ones in the following example.
Use the ls command to find the owner and group number:
$ ls -ln /opt/timesys/linux/6.1/i686-std/linux-x86-p3-basic/ total 0 drwxr-xr-x+ 2 11770 10513 0 Jul 29 2005 boot drwxr-xr-x+ 2 11770 10513 0 Jul 29 2005 dev drwxr-xr-x+ 2 11770 10513 0 Jul 29 2005 etc drwxr-xr-x+ 3 11770 10513 0 Jul 29 2005 lib drwxr-xr-x+ 3 11770 10513 0 Jul 29 2005 opt drwxrwxrwt+ 2 11770 10513 0 Jul 29 2005 tmp drwxr-xr-x+ 2 11770 10513 0 Jul 29 2005 tsrpm drwxr-xr-x+ 4 11770 10513 0 Jul 29 2005 usr drwxr-xr-x+ 3 11770 10513 0 Jul 29 2005 var
In this case the UID is 11770, and the GID is 10513. Thus, you should change the mapping file so that it looks like the following:
# Sample server map for nfsd # # This file maps 500/500 on an NFS client to the uid/gid of the # user who ran nfs-server-config, and maps 0/0 on an NFS client # the uid/gid of the Administrator account. # # Note that a server map is host-specific (which makes sense, # if you think about it...) So you can only use a plain IP # address or DNS name to specify a client that uses a map_static. # directive. # # Examples of valid /etc/exports lines using map_static: # # /gaunt 192.168.1.42(map_static=/etc/nfs/server.map) # /chaney twilley(map_static=/etc/nfs/server.map) # uid 0 11770 # user id for juser gid 0 10513 # group id for juser # uid 0 500 # user id for Administrator # gid 0 513 # group id for Administrator
Restarting the Services
After the DHCP and TFTP services have been configured, and the NFS mapping file has been created, you must restart the NFS daemons, the Internet services daemon, the port-mapping daemon, and the DHCP server. Refer to Restarting Required Services on Windows for more information.
Other Versions of Cygwin
Other versions of Cygwin might treat the nfs-server-config script differently. Refer to the document Troubleshooting Different Versions of Cygwin if you get errors running the script.