wm: doc

Download patch

ref: c74954a96cc6a377df317961565881dfc4a9e32e
parent: 6e4abec4022efff51d73e91fcae8ffdfd3e4f26e
author: mkf <mkf@cloud9p.org>
date: Mon Feb 12 15:37:19 EST 2024

nfs.ms: import

--- /dev/null
+++ b/nfs.ms
@@ -1,0 +1,110 @@
+.TL
+NFS in Plan 9
+.AU
+mkf
+.AI
+Cloud9p
+.AB
+Using NFS server in Plan 9
+.AE
+
+.SH
+Background
+.LP
+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.
+
+.SH
+Server
+.LP
+Plan 9 ships with a NFSv2 server, which is old, but works.
+it's code is located in
+.CW /sys/src/cmd/9nfs/nfsserver.c:63 .
+In order to use it, there is a helper script in
+.CW /rc/bin/service/startnfs .
+Unlike rest of scripts in
+.CW /rc/bin/service/
+this one needs to be executed manually (perhaps in cpurc).
+You may want to remove 
+.CW 9fs
+lines and tweak
+.CW aux/nfsserver
+arguments to add file servers you need to serve over nfs,
+for example, to serve
+.CW /srv/boot
+change
+.CW startnfs
+like:
+.P1
+aux/nfsserver -f /srv/boot -c /lib/ndb/nfs >>[2] /sys/log/nfsserver
+.P2
+to serve other directories, you can use
+.CW srvfs (8)
+in your cpurc.
+
+Afterwards, you need to change 
+.CW /lib/ndb/nfs ,
+Here is a example:
+.P1
+#server	client	uidfile	gidfile
+!9fs files
+\\.+	.+	/n/files/passwd	/n/files/group
+.P2
+
+Server and clients are in forms of regular expressions of domain names.
+Note that 
+.CW .+
+means all possible strings, and thus allows every computer to connect to your file system,
+this isn't usually what you want.
+You can limit clients that access your system by setting a more strict
+name instead of 
+.CW .+ .
+For example, for a setup that only allows 
+.CW unix.cloud9p.org :
+.P1
+\\.+	unix\.cloud9p\.org	/dev/null	/dev/null
+.P2
+
+Names are checked via their reverse DNS name,
+so you likely need to ensure it works (clients can't connect otherwise).
+.CW uidfile
+and 
+.CW gidfile
+are used to map users and groups of Plan 9 machine
+to UNIX uids and gids,
+they are
+.B NOT
+used for auth.
+Both may be
+.CW /dev/null .
+
+.LP
+Finally, to connect you may use the following command (in OpenBSD):
+.P1
+$ doas mount_nfs -2 server:spec /mnt
+.P2
+
+where spec is the name of file server you are sharing (via
+.CW -f
+or
+.CW -a
+).
+for example,
+.P1
+$ doas mount_nfs -2 wm:boot /mnt
+.P2
+to mount /srv/boot in /mnt.
+see
+.CW nfsserver (8)
+manual page for more information.