🏠💾 How to Turn a Raspberry Pi 4 into a NAS with Raspberry Pi OS & Samba


If you’ve got a Raspberry Pi 4 lying around, you can easily turn it into a Network-Attached Storage (NAS) device to share files across your network. This guide will show you how to set up Samba on Raspberry Pi OS to create a simple and efficient NAS solution. 🚀🔧
🛠️ What You’ll Need
Raspberry Pi 4 (or newer)
Raspberry Pi OS (Bookworm recommended)
An external USB storage device (HDD or SSD)
Ethernet cable or Wi-Fi connection
SSH access or a monitor and keyboard
1️⃣ Prepare Your Raspberry Pi
✨ Update Raspberry Pi OS
Before starting, update your system to the latest version:
sudo apt update && sudo apt upgrade -y
📂 Attach and Mount Your Storage
If you're using an external USB drive, check if it's recognized:
lsblk
Check if your drive appears:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 7.3T 0 disk
├─sda1 8:1 0 200M 0 part
└─sda2 8:2 0 7.3T 0 part /media/amastelek/G
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part /media/amastelek/amastelek
mmcblk0 179:0 0 29.7G 0 disk
├─mmcblk0p1 179:1 0 512M 0 part /boot/firmware
└─mmcblk0p2 179:2 0 29.2G 0 part /
🔹 A 2 & 8 TB drives are attached and mounted!
2️⃣ Install and Configure Samba
Samba is an open-source software that allows Windows, macOS, and Linux devices to share files.
🔹 Install Samba
sudo apt install samba -y
📝 Edit Samba Configuration
Open the Samba config file:
sudo nano /etc/samba/smb.conf
Add this to the bottom:
[Pi-SMALL]
path = /media/amastelek/amastelek
writeable = yes
create mask = 0777
directory mask = 0777
public = yes
valid users = amastelek, ronald, megs, ray
guest ok = yes
force user = amastelek
[Pi-LARGE]
path = /media/amastelek/G
writeable = yes
create mask = 0777
directory mask = 0777
public = yes
valid users = amastelek, ronald, megs, ray
guest ok = yes
force user = amastelek
📌 Save and exit (CTRL+X
, then Y
, then Enter
).
3️⃣ Enable and Restart Samba
sudo systemctl restart smbd
sudo systemctl enable smbd
4️⃣ Access Your NAS
💻 From Windows
Open File Explorer
In the address bar, type:
\\34DiasMedia\
(Use the Pi’s IP if the hostname doesn’t work:
\\<Pi-IP>\
)
🍏 From macOS
Open Finder
Press
Cmd + K
and enter:smb://34DiasMedia
Click Connect
🎯 Secure Access with User Authentication
For private shares, create a Samba user:
sudo smbpasswd -a ronald
Then, modify your smb.conf
to require authentication:
public = no
valid users = ronald
Restart Samba:
sudo systemctl restart smbd
Now, you'll need to log in with the username ronald and the password you set. 🔐
✅ Wrap
You've now turned your Raspberry Pi 4 into a fully functional NAS using Samba! Whether you're storing backups, streaming media, or just sharing files, this setup will serve you well. 📂🚀
Subscribe to my newsletter
Read articles from Ronald Bartels directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ronald Bartels
Ronald Bartels
Driving SD-WAN Adoption in South Africa