Setting up a Raspberry Pi with file sharing and screen sharing for Macs

I’m going to briefly explain how to setup a new Raspberry Pi as a basic desktop computer with file sharing and screen sharing so that Macs can connect to it.  This will be useful for quickly transferring files over, and taking control of the Pi remotely.  I will be assuming that you have basic command line knowledge (running commands, installing packages, editing text files), and some Mac knowledge.  I am not going to be too paranoid about security as I only intend on using my Pi on my home network, but if your Pi is going to be Internet-facing, you may want to read up elsewhere on securing your Pi.

Installing the Raspbian image onto the SD card

  1. Download the raw Raspbian image from Raspberry Pi website.
  2. Use Mac’s Disk Utility to format the SD card into one FAT partition.
  3. Download RPi-sd card builder. Use it to load the Raspbian image onto the SD card. (It will take a while… don’t take the SD card out until you get the final prompt and the cogwheel stops spinning in the menu bar)
  4. Plug the SD card into the Pi and boot up.
  5. Use the raspi-config tool that starts the first time you boot up to set the following options:
    1. Expand the root partition to fill the disk
    2. Enable SSH
    3. Start desktop on boot
    4. Change the hostname
    5. Change the default password
  6. Reboot the Pi, you should get into the desktop.
Raspbian Desktop Screen

The default Raspbian desktop screen

Setting up file sharing (AFP) and screen sharing (VNC)

  1. On the Raspberry Pi, open up LXTerminal.
  2. In LXTerminal, execute sudo apt-get install netatalk x11vnc to install the necessary packages.
  3. Execute x11vnc -storepasswd to setup the password required for your screen sharing connections.
  4. In order for the VNC server to start up at each boot, create the following file in ~/.config/autostart/x11vnc.desktop
    [Desktop Entry]
    Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer
  5. To register the VNC server as a Bonjour service, create the following file in /etc/avahi/services/rfb.service (you will need to save the file as root, so use sudo before opening your editor).
    <?xml version="1.0" standalone='no'?>
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
      <name replace-wildcards="yes">%h</name>

    If you don’t see an /etc/avahi folder, you may need to install the avahi package separately — recent netatalk packages will install avahi as a dependency, so if you’re doing a new install it shouldn’t be a problem.

  6. Reboot.  You should then be able to go into Finder and find your Raspberry Pi on the network.  File sharing and screen sharing should be accessible as well.

Raspberry Pi file sharing and screen sharing from a Mac

Backing up

After doing some customization of the Raspberry Pi, you may want to take a backup of it so that in case the SD card gets corrupted, you can easily restore the image. I found an excellent guide on this blog post. Summarizing it quickly:

  1. Plug the SD card into the Mac.
  2. In Terminal, execute diskutil list to find your SD card make note of the disk number (/dev/diskX)
  3. Then execute the following command for a backup: sudo dd if=/dev/rdiskX bs=1m | gzip > /path/to/backup.img.gz
    Replace the X with your disk number that you found in the previous step. Note the ‘r’ in /dev/rdiskX is intentional to take advantage of better performance (see the blog post I linked for details).
  4. For a restore, the command would be: gzip -dc /path/to/backup.img.gz | sudo dd of=/dev/rdiskX bs=1m

That’s it! This was a quick overview of getting a Raspberry Pi setup and talking with Macs for easy file transfers and remote control, and also backed up in case something bad happens.


One thought on “Setting up a Raspberry Pi with file sharing and screen sharing for Macs”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>