Build a Lightweight Home File Server with a Raspberry Pi and Samba

Network file sharing without buying a NAS

A NAS is a great bit of kit, but it’s also a significant purchase. If you just want to share files across your home network – a shared folder for the household, a media drive for your TV, a dump location for backups – a Raspberry Pi with an external drive does the job perfectly well, and you probably have most of the hardware already.

Samba is the software that makes this work. It’s the implementation of the SMB protocol that Windows, macOS, and Linux all understand natively, meaning your Pi will show up in Finder’s network sidebar and Windows Explorer’s network view like any other shared drive.

What you’ll need

  • Any Raspberry Pi with a network connection (wired strongly recommended)
  • An external drive – USB hard drive or SSD depending on your storage needs
  • About 20 minutes

Prepare the drive

Plug in your external drive. Find it with lsblk – it’ll typically appear as /dev/sda. If it needs formatting, ext4 is the sensible choice for a Linux file server:

sudo mkfs.ext4 /dev/sda1

Create a mount point and mount the drive:

sudo mkdir /mnt/storage
sudo mount /dev/sda1 /mnt/storage

To make it mount automatically on boot, add it to /etc/fstab. Get the drive’s UUID with blkid, then add a line like:

UUID=your-uuid-here /mnt/storage ext4 defaults,nofail 0 2

The nofail option means the Pi will still boot cleanly even if the drive isn’t plugged in.

Install and configure Samba

sudo apt update && sudo apt install samba -y

Edit the Samba config to add your share:

sudo nano /etc/samba/smb.conf

At the bottom of the file, add:

[Storage]
   path = /mnt/storage
   browseable = yes
   read only = no
   create mask = 0775
   directory mask = 0775
   valid users = @sambashare

Create a Samba user (use your Pi’s existing username):

sudo smbpasswd -a pi

Add the user to the sambashare group:

sudo usermod -aG sambashare pi

Restart Samba:

sudo systemctl restart smbd

Connecting from other devices

Windows: Open File Explorer, click “Network” in the sidebar, and your Pi should appear. Alternatively, map a drive directly using \<pi-hostname>Storage.

macOS: Open Finder, press Cmd+K, and enter smb://<pi-hostname>.local/Storage. You can also add it to your sidebar for quick access.

Linux: Most file managers handle SMB natively. In Nautilus, use “Connect to Server” and enter smb://<pi-hostname>.local/Storage.

Performance expectations

Over a wired connection, a Pi 4 with a USB 3.0 SSD can sustain 100โ€“115 MB/s – more than enough for streaming 4K video locally or doing fast file transfers. USB 2.0 drives and Wi-Fi will both limit throughput, so wire things up if you can.

Going further: multiple shares

You can add as many shares as you like to smb.conf – separate shares for different users, a read-only share for media, a shared family folder. Each is just another block in the config file. Samba’s user and group model is flexible enough to handle more complex permission setups as your needs grow.

This is part five of our “Things to do with your old Raspberry Pi” series. Next week: turning your Pi into a local smart home hub with Home Assistant.


Leave a Reply