Build a Raspberry Pi NAS with Samba File Sharing
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/sda1Add 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 0If 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 fstabInstall and Configure Samba
sudo apt update sudo apt install samba samba-common-bin -yEdit the Samba config to define your share:
sudo nano /etc/samba/smb.confAdd this block at the bottom:
[Storage] path = /mnt/storage browseable = yes writeable = yes create mask = 0775 directory mask = 0775 valid users = piSet 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 smbdConnect 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=piFixing 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/storagePerformance 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.
Related Guides
- Build a Raspberry Pi E-Ink Digital Photo Frame (Wired or Battery-Powered)
- Build a Cyberdeck: Custom Portable Computer with a Laser-Cut and 3D Printed Enclosure
- Build a PiKVM: Remote Out-of-Band BIOS/Boot-Level Access with a Raspberry Pi
- Build a Raspberry Pi Whole-Home Audio Streamer: Volumio, DAC HAT, and Multi-Room Sync
- Build an ADS-B Flight Tracker with Raspberry Pi and RTL-SDR
- Build a Battery-Powered Raspberry Pi Wildlife Trail Camera with PIR Trigger
- How to Install Klipper on Any 3D Printer: Complete Setup Guide
- How to Set Up OpenCV Machine Vision on a Raspberry Pi