• First Steps
  • General
  • Projects
Facebook Twitter YouTube
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
  • Hardware & GPIO
  • Sensors & Components
  • Scale
  • Cases
  • Fingerprint
  • Gas Sensor
  • Heartbeat
  • German
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
Home»Software»Raspberry Pi Samba Server: Share Files in the Local Network

Raspberry Pi Samba Server: Share Files in the Local Network

Facebook Twitter LinkedIn Tumblr Email Reddit
Share
Facebook Twitter LinkedIn Email Tumblr Reddit Telegram WhatsApp

More and more data is being stored in the clouds. This has the advantage that the files can be accessed from anywhere. However, these are usually stored in an online service, and not everyone wants that. If the data is only needed at home by several PCs, a Raspberry Pi Samba server is ideal: There is a central network storage device that all other devices can access while on the same network. This means that the files are not stored with third-party providers, and the transfer speed is also much higher.

The integration of a Samba server is very easy under Windows 10, Mac, Linux as well as Android and iOS. This means that images and documents can be processed by various devices at the same time. How to do this is explained in this tutorial.

Required Hardware Parts

First of all, we need a few components to be able to follow this tutorial. I have used the following:

  • Raspberry Pi
  • Micro SD card
  • Power supply (USB type C power supply)
  • Recommended: external hard drive

Since the Raspberry Pi can only deliver limited power via the USB 3.0 port, a hard drive with an external power supply is recommended. In addition, these are usually cheaper than small 2.5 inch external hard drives.

 

Install and Configure the Raspberry Pi Samba Server

……….

First, we bring the package sources up to date. To do this, open an SSH terminal and enter the following:

sudo apt-get update
sudo apt-get upgrade

Then we install Samba:

sudo apt-get install samba samba-common-bin

You will be asked whether the settings should be used by DHCP. Answer yes.

Raspberry Pi Samba Server utilitiesBefore we go on to the actual configuration, let’s take a look at how to use an external hard drive as a storage medium.

 

Mount the External Storage Device on the Raspberry Pi

First of all, the hard drive must be connected via USB (ideally to the USB 3.0 port). We then need the UUID of the device, which we can find out as follows:

ls -l /dev/disk/by-uuid/

Raspberry Pi External USB Stick

If you see multiple devices, you can run the command again when the hard drive is not connected and then compare. In my case, the UUID is 9678-B72E, which is shown under sda1.

Now we create a new folder (you can also create it somewhere else) that points to the contents of the storage device and give our user (pi) ownership rights to it:

sudo mkdir /media/usb
sudo chown -R pi:pi /media/usb

We mount the device:

sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi

 

That’s it already. One last point is the automatic mounting. This is recommended because it can happen that the Raspberry Pi has to be restarted. To do this, execute the following command:

sudo nano /etc/fstab

The following line must be added to the end of this file (with the correspondingly adapted UUID)

UUID=9678-B72E /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0

Save with CTRL + O and exit the Nano Editor with CTRL + X.

 

Create and Configure Shared Directory

The files can either be located directly on the hard drive or in a subdirectory. Of course, it is also possible to save the files on the SD card of the Raspberry Pi.

We create a new folder in the previously mounted directory:

mkdir /media/usb/share

 

Now we can edit the Samba configuration. But first, we create a backup (just in case):

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
sudo nano /etc/samba/smb.conf

Add the following section to the end of the file and save with CTRL + O.

[share]
Comment = Raspberry Pi Shared Folder
Path = /media/usb/share
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = yes

This configuration means that every user can read, write and execute files. Either a Samba user or a “guest” is authorized.

The Samba user (also called “pi”) has to get a password. This password can differ from the SSH password of the user. We hereby put it:

sudo smbpasswd -a pi

 

The last step on the Raspberry Pi is to restart the Samba server.

sudo service smbd restart

 

 

Setting up the Samba Server Under Windows 10, Mac, Android, iOS

Now we want to include the set-up share on a computer. To do this, we switch to the Windows PC.

Open “Start” and search for “Control Panel” -> “Programs” -> “Activate or deactivate Windows features” and activate “SMB 1.0 / CIFS File Sharing Support”. Then the PC has to be restarted.

After the restart, you can open a file explorer window and under “Network” there is now an entry with the name “RASPBERRYPI”. This contains the “share” folder in which all files can be stored.

Raspberry Pi Samba Network - Windows 10

You will be asked for your login details. Save this so you don’t have to enter it every time.

No reboot is necessary on Mac Systems. Here you can simply open a Finder window and select “Network” in the sidebar. Then select “raspberry pi” and the “shared” folder to get to the directory.

android FTP ftp server ios Network Connectivity proftpd USB Windows 10 Windows 8.1 windows OS
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleAnleitung: Günstige ESP8266 Waage bauen (mit Gewichtssensor HX711)
Next Article How-To: Bluetooth Verbindung Zwischen ESP32 und Raspberry Pi’s

Related Posts

Control all GPIOs with the Raspberry Pi REST API via Python

Using TensorFlow Lite with Google Coral TPU on Raspberry Pi 4

Build Live Text Recognition with the Raspberry Pi (OCR)

Raspberry Pi: Printer Setup and Printing Images by pressing a Button

2 Comments

  1. jpd on 24. June 2022 20:59

    Thank you for this excellent tutorial. I went through several sites on this subject and they all had inaccurate info which caused me to fail numerous times accomplishing this task, not to mention a mountain of frustration. All of them, except you, failed to mention that support for Samba isn’t enabled by default on Windows 11. They also gave inaccurate configuration settings. Thanks again, and keep up the good work.

    Reply
  2. Mike on 6. December 2022 12:22

    I second what jpd wrote. Having followed many tutorials without success activating “SMB 1.0 / CIFS File Sharing Support” was the key. Thank you

    Reply

Leave A Reply Cancel Reply

How to use a Raspberry Pi Fingerprint Sensor for Authentication

Control all GPIOs with the Raspberry Pi REST API via Python

Creating a Raspberry Pi SSL Certificate For Free With Let’s Encrypt

PiCar-X: Build a smart, self-driving robot car with the Raspberry Pi

Raspberry Pi as a Jukebox (Spotify, Soundcloud, TuneIn, and much more) – Online Radio

8×8 LED Dot Matrix – Assembly and Installation (Raspberry Pi)

Subscribe to Blog
Subscribe to Raspberry Pi Tutorials and don't miss any new Tutorial!
Subscribe

Thank you!

We will contact you soon.

Tutorials for Raspberry Pi
Facebook Twitter YouTube
  • Contact & Disclaimer

Type above and press Enter to search. Press Esc to cancel.