File Sharing on a Mac Network
You want your Raspberry Pi to appear on the list of computers on your Mac’s Finder so that you can connect to it and browse the filesystem using Finder.
The Mac OS X operating system includes built-in support for file viewing in Finder over the network (Figure 2-8). However, you must make some configuration changes on your Raspberry Pi for the Mac to pick these up.
You will need to know the IP address of your Raspberry Pi (Recipe 2.2).
Now, on the Raspberry Pi, install netatalk using the command:
$ sudo apt-get install netatalk |
Then, back on your Mac, in the Finder menu, select Go→Connect to Server and enter afp://192.168.1.16 as the server address (but use the IP address for your Raspberry Pi instead of the one shown here). Then click Connect. You will be prompted to log in. I had to reboot my Raspberry Pi before I got the login prompt.
Log in using the name pi and your password, which will be raspberry by default. The Finder should then show you the contents of your home directory on the Raspberry Pi.
Now there are a few more configuration changes to make on the Raspberry Pi.
$ sudo apt-get install avahi-daemon $ sudo update-rc.d avahi-daemon defaults |
Next type the command:
$ sudo nano /etc/avahi/services/afpd.service |
Paste the following code into the file.
<?xml version=”1.0″ standalone=’no’?><!–*-nxml-*–> <!DOCTYPE service-group SYSTEM “avahi-service.dtd”> <service-group> <name replace-wildcards=”yes”>%h</name> <service> <type>_afpovertcp._tcp</type> <port>548</port> </service> </service-group> |
To set the daemon running, type the command:
$ sudo /etc/init.d/avahi-daemon restart |
Switch back to your Mac, and you should now see your Raspberry Pi in the Finder.
Discussion
Being able to move files easily between your Mac and your Raspberry Pi is very useful. It means that you can use files on your Pi without having to hook up a separate keyboard, mouse, and monitor.
You can also open files on the Raspberry Pi as if they were on your Mac. This has the advantage that you can edit them with TextMate or your favorite Mac text editor.
If you’re using Windows or Linux, you can also share files by configuring your Raspberry Pi to work as NAS (Network Attached Storage); see Recipe 2.11.
See Also
The instructions here were adapted from this tutorial, which credits Matt Richardson and Shawn Wallace’s book Getting Started with Raspberry Pi (O’Reilly) as the original source.