Skip to content

File Server

This is a recipe for configuring a Raspberry Pi as a file-server. Once configured as a file-server, files on the Raspberry Pi can be easily opened/edited/copied from a remote computer. This is useful for copying recorded video off the Raspberry Pi to another (remote) computer for archiving and analysis.

If you are working on a Windows machine, you need to use Samba. If you are working on macOS you want to use AFP but can also use Samba.

2023 Install netatalk (AFP)

Following this tutorial.

Install netatalk

sudo apt install netatalk

Then configure netatalk.

The nano command will run a little text editor inside the terminal. Use the up/down arrows to position the cursor (not the mouse)

sudo nano /etc/netatalk/afp.conf

and copy/paste this at the end of the file

[$h]
    path = /home
    home name = $h

Exit nano with keyboard ctrl x

Restart netatalk with

sudo systemctl restart netatalk

To test this out, on a macOS computer select the main menu Go ... Connect to server ... and type afp:\\ followed by the IP address of your PI. In this example we are using 192.168.1.17 but your IP is most probably different.

afp:\\192.168.1.17

You should see your Pi mount onto your desktop or finder and you can start browsing files.

2023 Install SAMBA (SMB)

Following this tutorial.

Install samba

sudo apt-get install samba samba-common-bin

Make a folder to hold video (the PiE server requires this)

mkdir /home/pi/shared

Edit the smb configuration file with nano. You can move the cursor with up/down arow keys (not the mouse)

sudo nano /etc/samba/smb.conf

Copy and paste the following to the end of the file

[video]
path = /home/pi/video
writeable=Yes
create mask=0777
directory mask=0777
public=no

Set a samba password

sudo smbpasswd -a pi

Restart samba

sudo systemctl restart smbd

To test this out, on a macOS computer select the main menu Go ... Connect to server ... and type smb:\\ followed by the IP address of your PI. In this example we are using 192.168.1.17 but your IP is most probably different.

smb:\\192.168.1.17

Your Pi is now a samba file server !!! You could put your IT department out of business...

Old, Samba (SMB)

This is a recipe to make a Raspberry Pi a Samba (SMB) file-server that can be accessed from both Windows and macOS.

1) Install Samba

sudo apt-get install samba samba-common-bin

2) Edit /etc/samba/smb.conf

sudo pico /etc/samba/smb.conf

When using the pico editor, ctrl+x to save and quit, ctrl+w to search, ctrl+v to page down. Remember, the pico editor does not respond to mouse clicks, you need to move the cursor around with arrow keys.

3) Add the following to the end of the smb.conf file.

In the Pico editor, move the cursor to the end of the file and copy and paste the following.

[video]
Comment = Pi video shared folder
Path = /home/pi/video
Browseable = yes
Writeable = yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = no

[home]
Comment = Pi shared folder
Path = /home/pi
Browseable = yes
Writeable = yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = no

4) Create a Samba password

sudo smbpasswd -a pi

5) Restart Samba

sudo /etc/init.d/samba restart

6) Test the server from another machine on the network.

On a Windows machine, mount the Raspberry Pi Samba file-server with smb:\\[piIP] where [piIP] is the IP address of your pi. Do this by clicking the 'Start' menu and then typing smb:\\[piIP].

Old, Apple-File-Protocol (AFP)

This is a recipe to make a Raspberry Pi an Apple-File-Protocol (AFP) file-server that can be accessed from macOS.

1) Install netatalk

sudo apt-get install netatalk

Once netatalk is installed, the Raspberry Pi will show up in the macOS Finder 'Shared' section. The Pi can be mounted in the macOS Finder by going to Go - Connect To Server... and entering afp://[piIP] where [piIP] is the IP address of your Pi.

2) Changing the default name of a Pi in netatalk

When a Pi is mounted in macOS using AFP, it will mount as Home Directory. If you have multiple Raspberry Pi computers they all mount with the same 'Home Directory' name which can be confusing. Thus, you want to change the 'mount point' name of each Raspberry Pi. For more information, see this blog post to change the name of the mount point from 'Home Directory'. Or just follow along ...

Stop netatalk

sudo /etc/init.d/netatalk stop

Edit the netatalk config file

sudo pico /etc/netatalk/AppleVolumes.default

When using the pico editor, ctrl+x to save and quit, ctrl+w to search, ctrl+v to page down. Remember, the pico editor does not respond to mouse clicks, you need to move the cursor around with arrow keys.

Scroll to the bottom of the file and change this one line where 'the_name_you_want' should be the name you want the given Raspberry Pi to mount as. The '#' is used as a comment and is ignored.

# By default all users have access to their home directories.
#~/                     "Home Directory"
~/                      "the_name_you_want"

3) Restart netatalk

sudo /etc/init.d/netatalk start

4) Test the server from another machine on the network.

In the macOS Finder, go to Go - Connect To Server... and enter afp://[piIP] where [piIP] is the IP address of your Pi.