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
This is an example exports file to share ~/Movies and ~/Music/mpd
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
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
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
For example to mount the ~/Music/mpd Mac nfs share to ~/music on Freebsd we use a command simmilar to this
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
fstab nfs shares
Next we need to edit our /etc/fstab file and the nfs share details
Here is an example /etc/fstab with the noauto option
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
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
replacing username with your username
and to unmount the ~/music directory we run the following command
To mount the ~/Movies Mac nfs share to ~/movies we would run the following command
replacing username with your username
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