Skip to content

Share folder with Samba

Charrière Maxime edited this page Mar 3, 2021 · 3 revisions

In this Raspberry Pi Samba tutorial, we will be showing you how you can share directories from your RPi using a Samba server.
This way, you will be able to explore files in your RPi from your local OS file explorer.

Copatibilities

✔️ Linux
✔️ Windows
✔️ MacOS

Setting up Samba on your RPi

Use a remote terminal via SSH to write command on the RPi (see SSH tutorial).

  1. Update all apt packages

    sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
  2. Install Samba packages

    sudo apt-get install samba samba-common-bin

    If asked to activate Winds, accept

  3. Backup the Samba config file.
    The smb.conf configuration file is where you will store all your settings for your shares folders.
    For security (an accident happened quickly), copy the config file with this command

    sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_copy
  4. Open the Samba config file with nano

    sudo nano /etc/samba/smb.conf
  5. Modify the Samba config file
    Within this file, modify the following parameters under the [homes] section

    browseable = yes
    read only = no
    create mask = 0777
    directory mask = 0777
    

    Save and quit file (CTRL + X then Y followed by ENTER)

  6. Add a user
    Next, we need to set up a user for our Samba share on the RPi. Without it, we won’t be able to make a connection to the shared network drive.
    We will be creating a Samba user called pi with the password set to raspberry (as default).
    Run the following command then enter the password.

    sudo smbpasswd -a pi
  7. Restart Samba

    sudo systemctl restart smbd

Connect to the shared folder

On Windows

  1. Open File Explorer
  2. Go in This PC
  3. Under Computer tab, click Map network drive
  4. Under Folder enter \\raspberrypi\homes
  5. Select Connect using different credentials
  6. Finish
  7. Enter the network credentials created previously (pi and raspberry)
  8. The new shared folder corresponding to the home/pi folder of the RPi must appear in File Explorer.