A Network Attached Storage (NAS) device lets every computer, phone, and smart TV on your home network access a shared pool of files. Commercial NAS boxes from Synology or QNAP cost ₹15,000–₹60,000. A Raspberry Pi running Samba delivers nearly the same functionality for under ₹5,000—and you keep full control over your data.
This guide walks you through building a complete Raspberry Pi Samba file server from scratch: choosing hardware, configuring Samba shares, setting up user permissions, enabling automatic mounts, and tuning for maximum throughput. By the end, your Pi will appear as a network drive on Windows, macOS, Linux, and Android devices simultaneously.
Table of Contents
- What You Need
- Preparing the Raspberry Pi
- Formatting and Mounting Storage
- Installing and Configuring Samba
- Setting Up Shares and Permissions
- Connecting from Windows, macOS, and Linux
- Performance Tuning for Faster Transfers
- Advanced Features
- Frequently Asked Questions
What You Need
Building a Pi NAS requires surprisingly little hardware:
- Raspberry Pi 4 or Pi 5: Both have USB 3.0 ports for fast external drive access. The Pi 5 offers ~15% better Samba throughput due to its faster CPU and PCIe-capable USB controller.
- MicroSD card (32GB+ Class 10): For the OS only—don’t store files here.
- External USB hard drive or SSD: This is where your NAS data lives. A 2.5″ USB 3.0 SSD is ideal for speed; a USB HDD is fine for bulk storage.
- Ethernet cable: Essential for NAS use—Wi-Fi caps at ~40MB/s even on a good day; gigabit Ethernet delivers 100+MB/s.
- Official power supply: The Pi 5 requires the 27W USB-C PSU; the Pi 4 needs the 15W USB-C supply. Inadequate power causes random disconnects and data corruption.
Preparing the Raspberry Pi
Step 1: Flash the OS
Download and install Raspberry Pi Imager on your computer. Flash Raspberry Pi OS Lite (64-bit) to your microSD card. The Lite (headless) version is ideal for a server—no desktop environment means more RAM and CPU available for file serving.
Before writing, click the gear icon in Raspberry Pi Imager to:
- Set hostname (e.g.,
pi-nas) - Enable SSH
- Set username and password
- Configure your Wi-Fi (for initial setup—switch to Ethernet for production use)
Step 2: Initial Configuration
Boot the Pi, find its IP address from your router’s DHCP table, and SSH in:
ssh [email protected]
Update the system first—always:
sudo apt update && sudo apt upgrade -y
Step 3: Assign a Static IP
A NAS must always be at the same IP. The easiest method is a DHCP reservation in your router—reserve an IP for the Pi’s MAC address. Alternatively, configure a static IP in /etc/dhcpcd.conf:
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
Formatting and Mounting Storage
Step 1: Identify Your Drive
Connect your USB drive and run:
lsblk
Your drive will appear as sda (or sdb if another drive is connected). The partition will be sda1.
Step 2: Format the Drive
For maximum Linux performance, format as ext4. For compatibility with Windows (if you may connect the drive directly to a PC), use exFAT:
# For ext4 (recommended for NAS use)
sudo mkfs.ext4 /dev/sda1
# For exFAT (cross-platform compatibility)
sudo apt install exfatprogs
sudo mkfs.exfat /dev/sda1
Step 3: Create Mount Point and Mount the Drive
sudo mkdir -p /mnt/nasdata
sudo chown -R pi:pi /mnt/nasdata
For automatic mounting at boot, find the drive’s UUID:
sudo blkid /dev/sda1
Add to /etc/fstab:
UUID=your-uuid-here /mnt/nasdata ext4 defaults,noatime 0 2
The noatime option skips updating access timestamps—a significant performance improvement for a busy NAS.
Mount it now without rebooting:
sudo mount -a
Installing and Configuring Samba
Step 1: Install Samba
sudo apt install samba samba-common-bin -y
Step 2: Back Up the Default Config
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
Step 3: Configure smb.conf
Edit the Samba configuration file:
sudo nano /etc/samba/smb.conf
Replace the [global] section with:
[global]
workgroup = WORKGROUP
server string = Pi NAS
netbios name = pi-nas
security = user
map to guest = bad user
dns proxy = no
# Performance
read raw = yes
write raw = yes
max xmit = 65535
dead time = 15
getwd cache = yes
so options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=131072 SO_SNDBUF=131072
Setting Up Shares and Permissions
Public Share (No Password)
Add to the bottom of smb.conf:
[Public]
path = /mnt/nasdata/public
browseable = yes
read only = no
force create mode = 0666
force directory mode = 0777
guest ok = yes
Create the directory:
sudo mkdir -p /mnt/nasdata/public
sudo chmod 0777 /mnt/nasdata/public
Private Share (Password Protected)
Add to smb.conf:
[Private]
path = /mnt/nasdata/private
browseable = yes
read only = no
create mask = 0644
directory mask = 0755
valid users = pi nasuser
Create the Samba user and set a password:
sudo useradd -M -s /sbin/nologin nasuser # New user without login shell
sudo smbpasswd -a pi # Add existing pi user to Samba
sudo smbpasswd -a nasuser # Add nasuser to Samba
Apply Configuration
sudo testparm # Verify config syntax
sudo systemctl restart smbd
sudo systemctl enable smbd
Connecting from Windows, macOS, and Linux
Windows
Open File Explorer and type \pi-nas or \192.168.1.100 in the address bar. You’ll see the shared folders. Right-click a share and select “Map network drive” to assign it a drive letter (e.g., Z:) that appears every time Windows starts.
macOS
In Finder, press Cmd+K and enter smb://pi-nas or smb://192.168.1.100. Select the share and authenticate. To auto-mount at login: System Preferences → Users & Groups → Login Items → add the network share.
Linux
Install the SMB client tools and mount manually:
sudo apt install cifs-utils
sudo mkdir /mnt/pi-nas
sudo mount -t cifs //192.168.1.100/Private /mnt/pi-nas -o username=pi,password=yourpassword,uid=1000,gid=1000
Android/iOS
Use a file manager app with SMB support. On Android, Solid Explorer or MiXplorer work excellently. On iOS, the built-in Files app supports SMB—tap the three dots in Files → Connect to Server → enter smb://192.168.1.100.
Performance Tuning for Faster Transfers
Out of the box, Samba on a Pi 4/5 over gigabit Ethernet achieves 40–60 MB/s. With tuning, you can push this to 100–115 MB/s.
Samba Tuning Parameters
Add these to the [global] section of smb.conf:
min receivefile size = 16384
use sendfile = true
aio read size = 16384
aio write size = 16384
async smb echo handler = yes
SMB Protocol Version
Force SMB3 for maximum performance—SMB1 and SMB2 are slower and have security issues:
min protocol = SMB3
max protocol = SMB3
Linux Kernel Buffer Tuning
Add to /etc/sysctl.conf:
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
Apply: sudo sysctl -p
Use a USB SSD Instead of HDD
The single biggest performance improvement is switching from a spinning HDD to a USB 3.0 SSD. A typical USB HDD saturates at 50–80 MB/s sequential reads. A USB SSD easily exceeds 300–400 MB/s, making it impossible for the Pi’s gigabit Ethernet (which caps at ~115 MB/s) to be the bottleneck from the storage side.
Advanced Features
Automatic Backup with Rsync
Set up automated backups from your PC to the NAS using rsync over SSH:
rsync -avz --delete /home/user/Documents/ [email protected]:/mnt/nasdata/backups/documents/
Add to cron for nightly backups at 2AM:
0 2 * * * rsync -az /home/user/Documents/ [email protected]:/mnt/nasdata/backups/documents/
Add Plex Media Server
Your Pi NAS can double as a Plex Media Server. Install Plex and point its library to your NAS drive. The Pi 5 handles direct-play transcoding for 1080p content; 4K transcoding may require a more powerful host. With direct play (no transcoding), the Pi 5 serves 4K content without issue.
Monitor Disk Health with SMART
sudo apt install smartmontools
sudo smartctl -a /dev/sda
Set up weekly SMART tests in cron to catch drive failures before they cause data loss.
Enable Recycle Bin
Add this to each Samba share to enable a network recycle bin (deleted files go here instead of being immediately removed):
vfs objects = recycle
recycle:repository = .recycle
recycle:keeptree = yes
recycle:versions = yes
Frequently Asked Questions
How much storage can I attach to a Raspberry Pi NAS?
Theoretically unlimited via a powered USB hub. You can connect multiple USB drives and create separate shares for each, or use them in combination with LVM (Logical Volume Manager) to create a single large logical volume spanning multiple physical drives. A Pi 5 can handle 4+ USB drives simultaneously through a powered hub.
Is a Raspberry Pi NAS reliable enough for important data?
The Pi itself is very reliable—SBCs have no moving parts. The microSD card for the OS is the weakest link. Use a quality card and consider booting from USB SSD instead. Always maintain a backup of important data on a separate drive. The NAS drive itself (external USB) is as reliable as any external hard drive.
What transfer speeds can I expect?
Over gigabit Ethernet with a USB 3.0 SSD: 100–115 MB/s read, 80–100 MB/s write. With a USB HDD: 50–80 MB/s. Over Wi-Fi 5 (802.11ac): 30–50 MB/s. Over Wi-Fi 6: 50–70 MB/s. Wired Ethernet always wins for NAS use.
Can I access my Pi NAS remotely (outside home)?
Yes, via SSH tunneling, WireGuard VPN, or Tailscale (the easiest option). Install Tailscale on both the Pi and your laptop, and you’ll access the NAS from anywhere in the world as if you were on your home network. Avoid exposing Samba directly to the internet—it has a long history of vulnerabilities.
Can I run other services alongside Samba on the same Pi?
Absolutely. A Pi 4 or Pi 5 easily runs Samba alongside Pi-hole (DNS ad blocker), Nextcloud, Home Assistant, or a media server. Samba itself uses very little CPU in steady state—only during file transfers does it spike. A Pi 5 with 4GB or 8GB RAM comfortably handles all of these simultaneously.
Build Your Home NAS Today
A Raspberry Pi Samba file server is one of the most practical Pi projects you can build. Once set up, it runs silently 24/7 with negligible power consumption (Pi 5 draws ~3–5W idle), appears seamlessly on every device in your home, and gives you full control over your data without any cloud subscription.
The total project cost—Pi 5 + power supply + USB SSD—is a fraction of commercial NAS devices, and the result is equally capable for home use. With the tuning steps in this guide, you’ll achieve throughputs that rival dedicated NAS hardware.
Get started by picking up a Raspberry Pi board from Zbotic.in. We stock Pi 5 in 2GB, 4GB, and 16GB variants with fast delivery across India.
Add comment