NFS in Plan 9
- mkf
ABSTRACT
- Using NFS server in Plan 9
Background
Historically, there have been two ways to access remote file systems in UNIX. Sun's NFS and AT&T's RFS, ultimately NFS took over as de facto remote file system for UNIX. NFS had multiple versions, NFSv2 was first version that got released into public (and Plan 9 has a server for, but not a client), NFSv3 addresses some issues with old model and improves it in ways (and Plan 9 has a client for, but not a server). NFSv4 and later do some radical changes and makes it (more) suitable for a modern networked file system, however it is currently just supported by FreeBSD and Linux at the time of writing this guide.
Server
Plan 9 ships with a NFSv2 server, which is old, but works. it's code is located in /sys/src/cmd/9nfs/nfsserver.c:63. In order to use it, there is a helper script in /rc/bin/service/startnfs. Unlike rest of scripts in /rc/bin/service/ this one needs to be executed manually (perhaps in cpurc). You may want to remove 9fs lines and tweak aux/nfsserver arguments to add file servers you need to serve over nfs, for example, to serve /srv/boot change startnfs like:
aux/nfsserver -f /srv/boot -c /lib/ndb/nfs >>[2] /sys/log/nfsserver
#server client uidfile gidfile !9fs files \.+ .+ /n/files/passwd /n/files/group
\.+ unix.cloud9p.org /dev/null /dev/null
Finally, to connect you may use the following command (in OpenBSD):
doas mount_nfs -2 server:spec /mnt
doas mount_nfs -2 wm:boot /mnt