busy-bee.net buzz buzz buzz goes the honeybee home | blog | links | about me

linux to an imac

2002-08-09 10:45 / exporting read-write nfs directories  »

I've been trying to set up the imac (more specifically I suppose, a machine running Darwin) as an NFS server on my local domain. Now, there is a very good page here (pdf, as googled html) , that details all the NetInfo commands needed to set it up - all variations of niutil. However, no matter how much I mucked with the NFS options, e.g. niutil -createprop / 1235 "opts" "rw" "maproot=0", I couldn't get my directory to export read-write, just read-only.

So, I found this page (the relevant part a few paragraphs down), and there's another old-skool way to do it which unfortunately includes hacking a startup script: /System/Library/StartupItems/NFS/NFS, that'll probably be overwritten on every upgrade. An alternative to hacking would be to create one's own startup script, say myNFS and then turn the standard one off.

It's actually easier than the NetInfo way. You need an /etc/exports file, which has entries such as this for each exported directory: /export/bsdcvs -maproot=0 -network 192.168.0.0 -mask 255.255.255.0 (defaulting to read-write).

Now, the hack of /System/Library/StartupItems/NFS/NFS. The relevant part of mine looks like this:

if [ -f /etc/exports ]; then
    ConsoleMessage "Starting Network File System server"
    mountd /etc/exports
    nfsd -t -u -n 6
fi

#exports=$(niutil -list . /exports 2> /dev/null | wc -w)
#if [ "${exports}" -gt 0 ]; then
#    ConsoleMessage "Starting Network File System server"
#    mountd 

     # If the NetInfo config/nfsd directory contains 
     # startup args for nfsd, use those.
#    arguments=`niutil -readprop . /config/nfsd arguments`
#    nfsd ${arguments:-"-t -u -n 6"}
#fi

The commented-out code below is how it used to look. Note that we're doing a file existence test now rather than one using NetInfo.

Finally, HUP all the daemons - or reboot:

sudo kill -HUP `ps -aux | grep -E "nfsiod|nfsd|mountd|automount" | grep -v grep | awk '{print $2}'`

Oh, I'm pretty sure you need AUTOMOUNT and RPCSERVER set to -YES- in /etc/hostconfig before any of this will work.

Maybe there is a way to get the NetInfo way working - which would be preferable - but I couldn't see it. This way works, and my FreeBSD box will be happier with its donated disk-space.

mod_perl -- Speed, Power, Scalability