This document shows how to install a minimal Cygwin enviroment to host an NFS server.
If you’re using Windows XP, be sure to check out the last sections on firewall and network device problems before you try testing your configuration.
Please read the official documentation first
Things often change in the Cygwin project .After installing Cygwin and the nfs-server (see below) you will find the documentation here:
You need a directory for the Cygwin installation.
You will also need a place to archive the Cygwin packages. This should be where you keep other installers. For this example, we create the directory:
Enter this string in your browser’s address bar:
Download the installer (setup.exe) to:
Now run the setup.exe program. Press Next on the splash window and select
Install from Internet
Your root directory should be:
Select: “Install For: All Users”
Select: “Default Text File Type: Unix”
Specify your local package directory: (for example)
Press Next. Select: “Direct Connection” Press Next.
Choosing a mirror is tricky. You want to find a fast one. I’ve had good luck with:
A list of packages will rapidly appear in the setup window.
Installing extra packages
Several packages are needed beyond the default installation. If you’ve been messing around, press the “View” button repeatedly to cycle through to the “Category” view.
Click on the + sign next to the Editors category. Scroll down to find the “vim” item and click on the word “Skip.” Each time you click in this area, the text will change, scrolling through the available versions of the package. Often, it is a good idea to select the most recent version of the package. For example, “6.2-3″. The box in the “Bin?” column should be checked automatically.
Or you can add mono
A powerlfull but much simpler text editor because anybody who are not familiar with vi editor will probably face some dificulties :)
Click on the + sign next to the Editors category. Scroll down to find the “mono” item and click on the word “Skip.”
Click on the + sign next to the Net category. Scroll down to find the nfs-server item and click on the word “Skip” so it becomes “Install.” Select a recent version of the package. Note: The nfs-server is fairly new, so if you don’t see it in the Net category, back out and try a different Cygwin server.
This component is found in the Libs category. Scroll down to find the sunrpc item and click on the word “Skip” until it becomes “Install.” Select a recent version of the package.
This utility lets you configure the nfs server as a Windows system service. Click on the + sign next to the Admin category. Scroll down to find the cygrunsrv item and click on the word “Skip”. Select a recent version of the package.
All your packages as well as any packages they require will be downloaded and installed.
Configuring the server
Run the configuration script
In the cygwin shell window, run:
A number of warnings will appear about you installing cygwin for a single user, even though you didn’t. You can ignore these complaints.
Editing the configuration files
You probably need to learn the “vi” editor so you can easily create or modify Cygwin configuration files without installing all of X-Windows to support a GUI editor. You will be annoyed if this is your first exposure to vi. Give in. Learn it. It Is Your Destiny.
Otherwise, use Notepad and find some way to convert from windows to unix text format. (Try the drag-n-drop programs uf2d and df2u.)
Host access control files
If you perform the installation of cygwin as described above, you will not need to edit /etc/hosts.allow or /etc/hosts.deny. If you have installed tcp-wrappers by accident or because you decided to install everything, you will need to edit them:
To enable access by just one host:
To enable an entire subnet:
Comment out any lines that appear in this file. It will be empty unless you have chosen to install other Cygwin network packages.
The hosts.allow and hosts.deny files support more complex authorization schemes. See “man hosts_acccess” and “man hosts_options” if you need more precise control.
This is where you export local directories.
This example exports the /pub directory to everyone in the 148.150.62 subnet.
/pub 188.8.131.52/255.255.255.0(ro, no_root_squash)
The option “ro” means read-only. Use “rw” for read-write.
You cannot use the wildcard “*” in host numbers:
You can use the wild card in host names:
To use ip names, the name must be a real DNS name or it must in your /etc/hosts file.
Note: The Cygwin hosts file: /etc/hosts is actually a shortcut to your windows hosts file at:
For some reason, nfs mounts are MUCH faster if you don’t authorize entire subnets. It is better to list specific hosts.
If the user and group numbers on the client machine match those of an authorized user on the server, access is allowed based on the privilages granted to the user on the server.
Note: You can only have users & permissions in Cygwin if you are using NTFS in windows. If you have FAT32, you must connect as root from the remote system.
The root account is special. Access is never allowed to remote root users unless the “no_root_squash” option is used (as shown in the example above.)
The easy way is to access the server from a client running as root and use the no_root_squash option.
Starting the server
Start Menu/Programs/Administrative Tools/Services
There are three services associated with NFS:
Right-click on each of these and use the pop-up menu to start all three servers. You will find that portmap starts automatically when you start either nfsd or mountd first. There is a dependency between system services that Windows tries to maintain automatically.
After editing any of the configuration files the /etc directory, you must restart these services. Because mountd and nfsd are configured to depend on portmap, it is sufficent to right-click on portmap and select “restart.” A dialog will appear to confirm that you also want to restart mountd and nfsd.
Mounting an nfs share on the client machine
The client machine in the following example is assumed to be a Linux or other Unix system. If you have a nice free NFS client for Windows, I’d like to hear about it so I can add a link on this page.
For this example, we assume that the NFS server running on your Windows machine has an ip name “remote” and an exported directory “/pub” defined under /etc/exports as shown above.
The name “remote” only has to be defined on the Linux/Unix client. You can define the name in /etc/hosts or just use the ip number of your Windows server in the following example.
Log into your client machine. You probably need to be “root” to mount the remote nfs directory.
Create a local directory:
Mount the share:
mount -t nfs remote:/pub /mnt/there
You should now be able to poke around in /mnt/there, and see any files located in the “/pub” directory on the Cygwin/Windows side.
Important update: A reader of this HOWTO has discovered that CygwinNFS does not support NFS version 3, which is now the default in Linux. To overcome this problem you must add an option to the mount command line: “-overs=2″ The full command line becomes:
mount -t nfs -o nfsvers=2 remote:/pub /mnt/there
An alternative specification using “vers” also works on Linux and other Unix-like systems:
mount -t nfs -o vers=2 remote:/pub /mnt/there
(Thanks to Mr. Ostrozhansky!)
Exporting other Windows directories
If you run “mount” with no parameters in the cygwin shell, you will see a list of mounted directories.
The Windows root directories, c:\, d:\ etc will also appear in this list. They are accessed through the special path names /cygdrive/c, /cygdrive/d etc. If you visit the root “/” of cygwin, you will find that these mount points don’t actually exist. If you try to list them in the nfs /etc/exports file, they will fail to mount on the client system.
This is probably a bug, but there is a simple work-around:
Create a directory for each Windows volume you want to export and then mount them directly to the windows pathname:
Make directories to use as mount points:
mkdir -p /mnt/c
mkdir -p /mnt/d
Mount the windows directories:
mount c:/ /mnt/c
mount d:/ /mnt/d
Now you can export these directories in /etc/exports:
/mnt/c myClient.com(rw, no_root_squash)
/mnt/d myClient.com(rw, no_root_squash)
Don’t forget to restart the portmap service in Windows.
You may be worried about what happens to your mounts when you reboot windows: They are stored in the registry, rather than /etc/fstab. After a reboot, they are restored and they will be available to remote systems via NFS.
In fact, if you reboot windows when an nfs mount was created on a remote client, the mounted files will still be available after windows reboots.
Stop the services:
cygrunsrv –stop mountd
cygrunsrv –stop nfsd
cygrunsrv –stop portmap
Remove the services:
cygrunsrv –remove mountd
cygrunsrv –remove nfsd
cygrunsrv –remove portmap
If you use Cygwin to run other services such as X-Windows, you should stop these processes now.
Exit the shell and run the Cygwin setup.exe Use the “View” button repeatedly to cycle to the “Category” view, then click on the “Default” text next to category “All” to cycle through until you see Uninstall.
Press Next-> to remove everthing.
Cygwin is one of those programs that doesn’t really like to be uninstalled. To finish the job, delete everything in your c:\cygwin directory. You may find that you need to stop residual cygwin processes with the Task Damager before you can delete everthing in the Cygwin folder. Reboot if necessary.
Next, run Regedit and search for cygwin. Delete all the keys you find and any surrounding “Cygnus Solutions” folders.
Windows XP Issues
Many people report trouble running the NFS server under Windows XP. Since service pack 2, XP has a firewall which will block NFS connections by default.
A great thanks for Hugh Sparks who made this document.