Family Encyclopedia >> Electronics

Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

Network-attached storage (NAS) is essentially a shared drive accessible over your local network—the perfect home alternative to cloud storage for files too large for your devices or for seamless multi-device sharing. With a Raspberry Pi, you can create an affordable, efficient NAS without buying expensive hardware.

While options like OpenMediaVault (OMV) offer advanced features such as remote access, Samba stands out for its simplicity. It runs directly on your existing Raspbian OS, leaving your Pi free for other tasks. I've set this up on multiple Raspberry Pi models, including the Pi 4, and it's reliable for everyday use. OMV is worth exploring if NAS is your Pi's sole purpose.

What You'll Need

  • A Raspberry Pi (Pi 4, 3, or 2 recommended—Samba is lightweight).
  • Raspbian OS installed on an SD card.
  • A computer on the same network.
  • [Optional] External USB drive for expanded storage.

I've used a Raspberry Pi 4 with 4GB RAM successfully, but Pi 2 and 3 owners report great results too. A high-capacity microSD works for light use, but an external drive unlocks serious storage—even RAID setups with two drives for redundancy (we'll keep it basic here).

Start with a full system update:

sudo apt update && sudo apt -y upgrade

Step 1: Prepare Your Storage

Open a terminal on the Pi or via SSH.

If Using an External Drive:

Connect your USB drive. Format if needed (use GParted for GUI or terminal tools). Create a mount point:

Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide
mkdir /home/pi/FOLDERNAME

Name it anything, like "raspshare".

If Using Your SD Card:

Simply create a folder as above.

Step 2: Install Samba

Samba enables file sharing across Windows, Linux, and more. Install it with:

sudo apt install samba samba-common-bin
Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

Step 3: Configure Samba

Edit the config file:

sudo nano /etc/samba/smb.conf

Add this at the end (adjust path):

[sambadrive]
path = /media/pi/pisharedrive
writeable = Yes
read only = no
create mask = 0777
directory mask = 0777
public = no

[sambadrive] is your share name (used in access path). For SD folder, use /home/pi/raspshare. Set public=yes for open access or no for password protection. You can share multiple folders.

Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

Save (Ctrl+O, Enter) and exit (Ctrl+X).

Step 4: Create a Samba User

Add credentials for the default 'pi' user:

sudo smbpasswd -a pi
Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

Restart Samba:

sudo systemctl restart smbd

Step 5: Access from Windows

1. Open File Explorer.

Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

2. Click "Map network drive" (may vary by location).

3. Enter \RASPBERRYPI\sambadrive (or Pi's IP).

Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

4. Check "Connect using different credentials".

5. Finish and log in with pi credentials.

Build a Reliable NAS Server with Raspberry Pi: Expert Samba Guide

Your NAS is ready!

Final Notes

If write access fails, fix ownership:

sudo chown -R pi /home/pi/raspsharey

Avoid editing /etc/fstab unless necessary—it risks boot issues. This setup takes under 30 minutes, giving you always-on NAS when your Pi runs.

Image credits: Raspberry Pi 4 Model B

Read more:

  • How to turn your Raspberry Pi 4 into an Edge Gateway
  • How to install OSMC on a Raspberry Pi
  • How to build a DIY wireless printer with a Raspberry Pi