Build a Raspberry Pi NAS with Samba File Sharing
Raspberry Pi 4 (2GB+)
External USB 3.0 hard drive
Powered USB hub (recommended, especially for multiple drives)
microSD card
Prices and availability as of Nov 22, 3:16 AM ET and subject to change. The price shown on Amazon at the time of purchase applies.
Turn a Raspberry Pi into a proper Network Attached Storage box — a shared drive any Windows, Mac, or Linux machine on your network can access like a regular folder, at no ongoing cost beyond the hardware itself.
Install the OS
Flash Raspberry Pi OS Lite (headless, no desktop needed for a file server) and enable SSH directly in Raspberry Pi Imager's settings before first boot — no need to connect a monitor at all.
Mount Your Storage Drive
# Find your connected drive
lsblk
# Create a mount point
sudo mkdir -p /mnt/storage
# Mount it (replace sda1 with your actual drive identifier)
sudo mount /dev/sda1 /mnt/storage
# Get the drive's UUID for a permanent mount
sudo blkid /dev/sda1
Add the drive to /etc/fstab so it mounts automatically on every boot:
sudo nano /etc/fstab
# Add this line (replace UUID and filesystem type with yours):
UUID=your-uuid /mnt/storage ext4 defaults,auto,users,rw,nofail 0 0
If the drive is NTFS-formatted (common if it was previously used with Windows):
sudo apt install ntfs-3g -y
# Use "ntfs" instead of "ext4" as the filesystem type in fstab
Install and Configure Samba
sudo apt update
sudo apt install samba samba-common-bin -y
Edit the Samba config to define your share:
sudo nano /etc/samba/smb.conf
Add this block at the bottom:
[Storage]
path = /mnt/storage
browseable = yes
writeable = yes
create mask = 0775
directory mask = 0775
valid users = pi
Set Your Samba Password and Start the Service
# Add your Pi user to Samba (use your actual Pi username)
sudo smbpasswd -a pi
# Enter and confirm a password — this is separate from your SSH login password
sudo systemctl restart smbd
sudo systemctl enable smbd
Connect From Other Devices
Windows: Open File Explorer and type \\piname.local\Storage in the address bar, then enter your Samba credentials.
Mac: Finder → Go → Connect to Server → smb://piname.local/Storage
Linux:
sudo apt install smbclient cifs-utils
sudo mount -t cifs //piname.local/Storage /mnt/piserver -o username=pi
Fixing Permission Issues
If you can connect but can't actually write files to the share, fix ownership and permissions on the mounted drive directly:
sudo chown -R pi:pi /mnt/storage
sudo chmod -R 775 /mnt/storage
Performance Expectations
- A Pi 4 with a USB 3.0 drive over gigabit Ethernet realistically gets 40-80 MB/s — genuinely solid for home NAS use, comparable to many budget dedicated NAS boxes.
- Gigabit Ethernet is dramatically faster than WiFi for large file transfers — worth running a real cable to the Pi if the NAS will see much traffic.
- Format storage drives as ext4 rather than NTFS when possible — meaningfully better read/write performance on a Linux-based file server.
Tips
- Use a powered USB hub for external hard drives — the Pi's own USB ports often can't reliably supply enough current for spinning drives, especially more than one at a time.
- Set a static IP (or a DHCP reservation on your router) so the share's address never changes and you don't have to reconfigure client connections after a reboot.
- For multiple drives, a powered hub isn't optional — budget for it from the start rather than troubleshooting mysterious drive dropouts later.