Installing Samba on your Raspberry Pi Buster and optimizing it for macOS computers

Installing Samba on your Raspberry Pi Buster and optimizing it for macOS computers 1

File sharing is one of the basic functionalities of an operating system. But if you install Buster on your Raspberry Pi, you still need to add the Samba software to make your Pi accessible in a Windows/macOS or Linux environment.

Although this is relatively straight forward, there are several things that have changed over time and many tutorials on the web are outdated in this regard. After all, Samba has been around since 1992 to provide file and print services to all manner of SMB/CIFS clients.

The recent Raspbian Buster release and Apple’s shift from AFP to SMB has also brought about some changes, and this tutorial will explain to you especially how to optimize your Raspberry Pi Samba setup for macOS computers in your network. All this will, of course, also work for connected Windows and Linux computers.


You have installed the latest “Raspbian Buster with desktop” version on your Pi and are connected to the Internet. If you don’t know how to do that, you can look here.

I also assume that you are connected to your Raspberry Pi via ssh in a Terminal window.

Alternatively, you can do the same on your Raspberry Pi if you have a monitor and a keyboard connected to it. As many Pi are used as headless systems, ssh’ing into the Pi has become a popular way.

Before you install new packages, you should always run a system update with

sudo apt update && sudo apt upgrade -y

Samba works with all Raspberry Pi models, but file sharing is much faster with the Raspberry Pi 3 (theoretically Gigabit but hampered by the USB 2.0 bus speed resulting in ~224 Mbps) and especially with the Pi 4 and its Gigabit ethernet port (over 900 Mbps).

If you expect decent file-sharing performance from your Raspberry Pi, get a Model 4 with 2 or 4 GB of RAM.

If you only need the occasional file exchange like for a digital picture frame, then the maximum speed doesn’t matter that much.

AFP, Bonjour and Avahi

As I mentioned earlier, there are many Raspberry Pi networking tutorials on the web that suggest installing several packages that you don’t need anymore. Let’s go through the most often mentioned ones.

Apple originally used AFP (Apple Filing Protocol) but moved over to SAMBA (SMB) in macOS 10.9 Mavericks released in 2016. You will still find many tutorials about installing AFP with Netatalk, but I don’t see any reason to stick with legacy technology. SMB 3 (the latest version) is faster than AFP and provides all features that you would need for your Mac (like Time Machine compatibility). Conclusion: Forget about installing AFP on your Pi, use SAMBA instead.

Bonjour is Apple’s wonderful technology that automatically locates and displays devices and services like computers, file shares, or printers that are available on a network. It is built in macOS but also available for Microsoft Windows. To allow the Raspberry Pi to propagate itself across a network and to be recognized by Bonjour, you needed to install the Avahi package separately. The latest Raspbian Buster version includes this right out of the box, so no need for installing it.

To summarize: All you need for Raspberry Pi file sharing is SAMBA.

Installing Samba

In the Terminal window enter

sudo apt install samba -y

When this window comes up, choose “No”.

Installing Samba on your Raspberry Pi Buster and optimizing it for macOS computers 2

If you want to access other network computers from your Raspberry Pi, e.g., when you use it as a desktop computer, you will need also to install the CIFS tools. They were originally part of the Samba package but later split into their own package.

For an application like a digital picture frame where you don’t need to see other computers but just be visible in the network yourself, you won’t need to install this.

sudo apt install samba-client cifs-utils

Installing a user

This is very easy. If your username is “pi”, type

sudo smbpasswd -a pi

Just replace pi with whatever your user name is, set a password and confirm it. You can add as many users as you like.

The SAMBA config file

SAMBA comes with an elaborate config file that allows you to specify your network exactly as you want it. When you open it for the first time, you might be slightly overwhelmed by its length, but most of the file is just filled with instructions and explanations. The core is quite compact.

If you like, you can delete all the “#” comments (CTRL-K to remove lines in the editor), but they won’t make your system faster. Just a bit more Marie-Kondo-minimal.

Open the SAMBA config file with

sudo nano /etc/samba/smb.conf

The config files has two main segments: Global Settings and Share Definitions.

In Global Settings, you define the general behavior, like authentication, network restrictions, and logging.

The Share Definitions specify the folders that you want to share and the kind of access that you want to grant to users, groups and everyone else. The printer network is also in this section.

To optimize the global section for macOS computers in your network, you may find the following lines quite useful.

They add some tweaks for macOS and create a nice sidebar symbol for the Raspberry Pi (based on the RackMac). I found that not doing this would create a rather unsightly question mark symbol next to my Raspberry Pi share on Model 4 running Raspbian Buster.

Just add these lines directly below [global]:

min protocol = SMB2
vfs objects = catia fruit streams_xattr
fruit:metadata = stream
fruit:model = RackMac
fruit:posix_rename = yes
fruit:veto_appledouble = no
fruit:wipe_intentionally_left_blank_rfork = yes
fruit:delete_empty_adfiles = yes

For all full overview of the various settings in this segment, I recommend a look at this page.

Now scroll down to the last section called “Share Definitions”.

When I am working on my digital picture frame project, I like to be able to access the Raspberry’s home directory. Some people will tell you that is a security risk, but if you do regular system updates and set your password to something else than “123” or “pi” you should be in good hands.

So to share your home directory, or any directory for that matter, for a registered user (like “pi”) insert this code:

   comment = Pi Directory
   path = /home/pi
   browseable = yes
   read only = no
   guest ok = no
   create mask = 0700
   directory mask = 0700
   valid user = %S

If you want to share just your Pictures folder but with everyone, put it like this:

   comment = Pictures
   path = /home/pi/Pictures
   browseable = no
   read only = no
   guest ok = yes
   create mask = 0775
   directory mask = 0775

You can restrict access to your folders in many ways. “0700” would only allow the user to modify the files. For further study on this subject I recommend this article.

When you are done with your modifications, hit CTRL + O to write the file to disk and CTRL + X to exit the editor.

To test the syntax of your config file or see a summary of the settings, enter

testparm /etc/samba/smb.conf

Finally, restart SAMBA:

sudo /etc/init.d/smbd restart

You should now see the name of your Raspberry Pi in your network. Connect to it using your username “pi” (in our example) and your password.

Whenever you reboot your Raspberry Pi, file sharing will automatically start.

Networking is sometimes a bit slow to recognize changes. If you are using macOS and you don’t see your Raspberry Pi after you made some changes, I recommend relaunching the Finder (Apple Menu > Force Quit).

Installing Samba on your Raspberry Pi Buster and optimizing it for macOS computers 3


I hope this post was helpful for you to install SAMBA on your Raspberry Pi and to optimize it for the macOS machines on your network.

As always, I’d be happy to hear from you if you have any comments or suggestions.

Wolfgang Männel

Photography has always been a passion of mine. Since 2005, I have looked at countless ideas on how to enjoy beautiful images digitally, making the experience entertaining, amusing, and stimulating. In my other life, I am an entrepreneur, consultant, and bicyclist based near Frankfurt am Main, Germany.

Recent Content