NFS

Setting up a nfs server

Edit the exports file

Edit /etc/exports and add a line like this:

/home/acorn/path/of/dir 192.168.0.1(async,rw,all_squash,anonuid=500,anongid=500)

Replace /home/acorn/path/of/dir with directory to export.

Replace IP address (192.168.0.1) with IP addr of client machine that will be mounting filesystem.

Replace anonuid=500,anongid=500 with uid and gid of account that should be used to access. For example set it to the "nobody" uid/gid. See /etc/passwd on server. The IP address is the machine that will be able to mount it. Replace it with * to allow any machine to mount. You can also use a machine domain name, and * in the name works as a wildcard (e.g. *.foo.com accepts any machine at foo.com).

The entire IP address plus following parenthesized options can be repeated several times (space separated) to allow multiple machines to access. Each gets its own set of options.

See man exports for options.

async - speeds things up (but means a server crash can lose data).

rw - allow read/write access (default is ro)

no_root_squash - allow root on client to access files as root on server. By default client root accesses files on the server as if it was the "anon" uid and gid.

all_squash - make all accesses to the server look like they came from the "anon" uid and gid. Use this especially if the client uid/gid numbers do not match the ones on the server (compare /etc/passwd on both machines).

anonuid - the "anon" uid. With all_squash all accesses will have permissions of this uid. Usually set to "nobody" uid (default). Set to "acorn" uid to allow more access. Not needed if all_squash is not used.

anongid - the "anon" gid. See anonuid.

restart NFS

Use

    sudo service nfs restart
or
    sudo /etc/init.d/nfs restart
(replace restart with start or stop to start or stop the server.)

Setting up the client

Mount (for temporary use)

Use

	mkdir /path/to/targetdir
	sudo mount server:/home/acorn/path/of/dir /path/to/targetdir
to mount it. To unmount
    sudo umount /path/to/targetdir

replace server with name (or IP) of server.

replace /home/acorn/path/of/dir with path on server of directory to mount - must be in /etc/exports on server.

replace /path/to/targetdir directory on client machine where it will be mounted.

Mount (regular use)

Add this line to /etc/fstab file:

server:/home/acorn/path/of/dir /path/to/targetdir nfs user,noauto,exec 0 0

This will allow any user to mount it with the command

    mount /path/to/targetdir
and unmount it with
    umount /path/to/targetdir
. To only allow root to do this remove the user option.

To have the dir automatically mounted on reboot replace noauto with auto. This can make rebooting slow if the server is not available (e.g. if networking is not available).