Other Mounting a nfs share from Mac osx on Freebsd

You would think sharing files from Mac osx to Freebsd would be easy,
just open the Mac osx system preferences sharing section and click the checkbox next to file sharing

Unfortunately the sharing protocols are afp or smb.

Im not sure if netatalk still works with afp,
and mount_smbfs on Freebsd doesnt seem to support the authentication method used by the mac's version of smb

But Mac osx still supports creating nfs shares

I think there used to be a section in the Disk Utility application on the Mac to configure nfs share but Apple removed it,
so there isnt a built in gui tool to set up nfs share's on the Mac you have to create the them the old fashioned way with a text editor and the terminal

Create the exports file

You have to create /etc/exports which in this example will contain:

the directory you are sharing
-mapall=user - Specifies that all remote users should be mapped to the specified user.
and the ip address of client

However this being a Mac of course there is a catch

Apple has decided in its infinite wisdom to make /etc read only so when you try to add a file to the /etc directory,
you get a pop up asking if you want to allow the Terminal access and the file you added will then be changed to read only.

Im not sure if this security measure is related to System Integrity Protection on the Mac or a separate feature
But the pop dialog box appears every time you try to add a file to the /etc directory

Lets create a text file called exports with the nfs share details on the Desktop,
then copy the fie to /etc directory and then start the nfs server

In this example i will create nfs shares for the Movies and Music directories on the Mac we can share to Freebsd,
the iTunes library is in the ~/Music directory so we will create a sub directory in ~/Music with our audio files which will share

Create a directory called mpd or whatever you like in the ~/Music directory

Bash:
mkdir -p ~/Music/mpd

This is an example exports file to share ~/Movies and ~/Music/mpd

Bash:
/Users/username/Music/mpd -mapall=username 192.168.1.3
/Users/username/Movies -mapall=username 192.168.1.3

replace username in the file path with your user name
replace mapall=username with the user name of the Mac account
and change the ip address to the ip of the nfs client which in this case will be out Freebsd machine
you can add multiple ip address separated by white space

Copy the exports file to /etc

Next we need to copy the exports file to the /etc directory

Bash:
sudo cp exports /etc

click allow terminal access in the pop up

Note the /etc/exports file will be marked as read only in the /etc directory

If you need to make changes to the exports file you can delete /etc/exports file and copy a new version to /etc,
but you will get the pop dialog box asking to allow terminal access everytime you try and copy a file to /etc

Start the nfsd server

Start the nfs server every time the mac boots

Bash:
sudo nfsd

Mount the nfs share on Freebsd manually

Use the mount command as root to mount the nfs share replacing the ip address with the ip of the nfs server running on the Mac,
and replace the remote and local usernames

You also need to make sure the local mount point by creating the ~/music directory on Freebsd

Bash:
mkdir -p ~/music

For example to mount the ~/Music/mpd Mac nfs share to ~/music on Freebsd we use a command simmilar to this

Bash:
# mount -o rw -t nfs 192.168.1.101:/Users/username/Music/mpd /home/username/music

To mount the ~/Movies Mac nfs share to ~/movies on Freebsd we use a command simmilar to this,
making sure the local mount point exists first of course

Bash:
# mount -o rw -t nfs 192.168.1.101:/Users/username/Movies /home/username/movies

fstab nfs shares

Next we need to edit our /etc/fstab file and the nfs share details

Bash:
# vim /etc/fstab

Here is an example /etc/fstab with the noauto option

Bash:
192.168.1.101:/Users/username/Music/mpd /home/username/music nfs rw,noauto,noatime 0 0
192.168.1.101:/Users/username/Movies /home/username/movies nfs rw,noauto,noatime 0 0

Replace the ip address with the ip of the nfs server running on the Mac,
and replace the remote and local usernames with your username

We use the noauto option to stop the nfs share from being mounted when Freebsd boots

If you want to mount the nfs share automatically at boot you would omit the noauto option in your fstab

Here is an example /etc/fstab without the noauto option to mount the nfs share automatically at boot

Bash:
192.168.1.101:/Users/username/Music/mpd /home/username/music nfs rw,noatime 0 0
192.168.1.101:/Users/username/Movies /home/username/movies nfs rw,noatime 0 0

Mount the nfs share from fstab


To mount the nfs share from our fstab file we use the mount command and the path to our local mount point

For example to mount the ~/Music Mac nfs share to ~/music we would run the following command

Bash:
# mount /home/username/music

replacing username with your username

and to unmount the ~/music directory we run the following command

Bash:
# umount ~/music

To mount the ~/Movies Mac nfs share to ~/movies we would run the following command

Bash:
# mount /home/username/movies

replacing username with your username
 
No offense, it's nice that you share your knowledge on a regular basis, but I find it very annoying that you are spamming forum sections, which are ment to ask questions, with your tutorials all the time.

Additionally, it's often not clear if you are posting a question (that's what people expect in forums others then "Howtos and FAQs") or a tutorial.

For me (and certainly others, too) it sucks to read a thread title that looks like a question and when I then decide to have a look at it, when I have already read half way through your post, I find out it's not a question, but a tutorial.

Why don't you post in "Howtos and FAQs" where such things belong?
 
While I agree with k.jacker that it is not clear (at least to me) what section of the forum is ideal for this ...

I would also like to thank you for posting such detailed instructions. Sharing data between "closely related" operating systems is often not trivial, and having good step-by-step instructions where they can be found by a web search is great. Other people (including me) will be able to benefit from your patience and diligence.
 
No offense, it's nice that you share your knowledge on a regular basis, but I find it very annoying that you are spamming forum sections, which are ment to ask questions, with your tutorials all the time.

Additionally, it's often not clear if you are posting a question (that's what people expect in forums others then "Howtos and FAQs") or a tutorial.

For me (and certainly others, too) it sucks to read a thread title that looks like a question and when I then decide to have a look at it, when I have already read half way through your post, I find out it's not a question, but a tutorial.

Why don't you post in "Howtos and FAQs" where such things belong?
Do you know how much money i was raking in by spamming the forum with subliminal adverts disguised as tutorials,
if you had kept quiet i would have cut you in on the deal, we could have been on a nice little earner.

Its not easy to pass off a subliminal advert as a tutorial about setting up an nfs server on a lttle old Mac,
it takes a lot of know how to get past the mods and SirDice, at any rate i prefer a Big Mac.

You probably didnt even spot the subtle subliminal message i had inserted into my forum posts

I would have got away with it if it wasnt for those pesky kids
 
Thank you for your very informative and intelligent answer. I wonder why I didn't add you to my V.I.P. list much earlier.
 
Back
Top