NFS HOWTO : Setting up a NFS server : Mountd and nfsd
Previous: The portmapper
Next: Setting up a NFS client

3.4. Mountd and nfsd

The next programs we need running are mountd and nfsd. But first we'll edit another file. /etc/exports this time. Say I want the file system /mn/eris/local which lives on the machine eris to be available to the machine called apollon. Then I'd put this in /etc/exports on eris:


/mn/eris/local	apollon(rw)

The above line gives apollon read/write access to /mn/eris/local. Instead of rw it could say ro which means read only (if you put nothing it defaults to read only). There are other options you can give it, and I will discuss some security related ones later. They are all enumerated in the exports man page which you should have read at least once in your life. There are also better ways than listing all the hosts in the exports file. You can for example use net groups if you are running NIS (or NYS) (NIS was known as YP), and always specify domain wild cards and IP-subnets as hosts that are allowed to mount something. But you should consider who can get access to the server in unauthorized ways if you use such blanket authorizations.

Note: This exports file is not the same syntax that other Unixes use. There is a separate section in this HOWTO about other Unixes exports files.

Now we're set to start mountd and then nfsd. They will both read the exports file.

If you edit /etc/exports you will have to make sure nfsd and mountd knows that the files have changed. The traditonal way is to run exportfs. FreeBSD lacks a exportfs program. You can install this script on your machine:


#!/bin/sh
/bin/kill -HUP `/bin/cat /var/run/mountd.pid`
echo re-exported file systems

Save it in, say, /usr/local/sbin/exportfs, and don't forget to chmod a+rx it. Now, whenever you change your exports file, you run exportfs after, as root.

Now you should check that mountd and nfsd are running properly. First with rpcinfo -p. It should show something like this:


   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    100005    1   udp    745  mountd
    100005    1   tcp    747  mountd
    100003    2   udp   2049  nfs
    100003    2   tcp   2049  nfs

As you see the portmapper has announced it's services, and so has mountd and nfsd.

If you get rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused or something similar instead then the portmapper isn't running. Fix it. If you get No remote programs registered. then either the portmapper doesn't want to talk to you, or something is broken. Kill nfsd, mountd, and the portmapper and try the ignition sequence again.

After checking that the portmapper reports the services you can check with ps too. The portmapper will continue to report the services even after the programs that extend them have crashed. So a ps check can be smart if something seems broken.

Of course, you will need to modify your system rc files to start mountd and nfsd as well as the portmapper when you boot. It is very likely that the scripts already exist on your machine, you just have to uncomment the critical section or activate it for the correct init run levels.

Man pages you should be familiar with now: portmap, mountd, nfsd, and exports.

Well, if you did everything exactly like I said you should you're all set to start on the NFS client.


NFS HOWTO : Setting up a NFS server : Mountd and nfsd
Previous: The portmapper
Next: Setting up a NFS client