Step one - exporting and importing filesystems.
You can export filesystems from an OS X mac quite easily, both NFS and AFP, and import them on another box. I wanted to share music and video.
Everything is set up in Netinfo Manager, run it from the Utilties folder in Startup. If these are your first AFP or NFS shares you may have to reboot after adding entries as some of the daemons only run on startup and if there are no shares, do nothing. You can start them by hand if you like.
/System/Library/StartupItems contains some of the startup scripts, take a look to see how they start things. The ones we care about are NFS and AppleShare.
1) Exporting NFS Shares
These are exported in the Netinfo Manager section /exports, create it if you don't have it. I found I had to do that as root with the following command line.
sudo niutil -create / /exports
You can dump out the contents of a particular piece of Netinfo with the nidump command.
nidump -r /exports /
gives you a listing of the whole exports entry.
Now you need to add a directory entry for each filesystem you want to export. The properties required for each entry are name and opts.
name is both the name of the property in Netinfo and must be the path of the directory you're going to share, like /export/music or /Users/Johnny.
opts is a multi-valued property, use New Value or Insert Value in the Netinfo Manager. Here you put all the arguments you want the mount daemon to use, look at the man page for exports(5). I have ro and mapall=nobody.
$ nidump -r /exports /
{
"name" = ( "exports" );
CHILDREN = (
{
"name" = ( "/Users/rols" );
"opts" = ( "ro", "mapall=nobody" );
}
)
}
Restart, or send mountd a HUP signal (see the mountd man page) and your filesystems should be exported. To see what you're exporting, use showmount
$ showmount -e
Exports list on localhost:
/Users/blah Everyone
2) Exporting AFP Shares
AFP share definitions are in the config/SharePoints subdirectory of Netinfo. Here's my netinfo dump for one share
$ nidump -r /config/SharePoints /name is the name of the entry in sharepoints, not necessarily the name of the share.
{
"name" = ( "SharePoints" );
"CHILDREN" = (
{
"name" = ( "Music" );
"directory_path" = ( "/export/Music" );
"afp_shared" = ( "1" );
"afp_name" = ( "Music" );
}
)
}
directory_path is the local path to the directory you are sharing
afp_name is the name by which this share is shared.
after struggling with these for a while and getting some set up I found an application called SharePoints (I was searching for config/SharePoints) which I highly recommend for setting up your shares. It will also let you share via SMB.
3) Importing filesystems
Once you have exported filesystems, you need to import them on the client.
Importing NFS
NFS shares can be mounted by hand with mount to test them. To mount /export/Music shared from mini you'd do something like this
mkdir a
mount -t nfs mini:/export/Music a
umount it with
umount /a
rmdir a
entries in NetInfo are like the following. vfstype is nfs, dir is unimportant (the directory is remapped by automount anyway), the name represents where in the hierarchy it's mounted (in this case /System/Network/
Importing AFP
{
"name" = ( "192.168.45.16:/export/Music" );
"dir" = ( "/mnt" );
"opts" = ( "net", "-s", "-b" );
"vfstype" = ( "nfs" );
}
AFP imports go in mounts as well, but they are imported with vfstype 'url'. Again if you have an 'opts' entry with 'net' as one value, it will be automounted.
The name value represents what the filesystem will import as, you can pick anything you like.
The URL is the key to the import, firstly it must be specified as URL==, note the double =. The url is of the form
afp://username;passwd@server/Sharename
for anonymous shares it looks like this afp://;AUTH=NO%20USER%20AUTHENT@
afp://;AUTH=NO%20USER%20AUTHENT@123.123.123.123/Music
here's an entry from my config/SharePoints for an AFP import
{
"name" = ( "mini:/Music" );
"dir" = ( "/mnt" );
"opts" = ( "net", "url==afp://;AUTH=NO%20USER%20AUTHENT@123.123.123.123/Music" );
"vfstype" = ( "url" );
}