Build a Raspberry Pi NAS for Network File Storage
A Pi 4 or Pi 5 with USB 3 and a decent external drive makes a quiet, low-power home file server. Family devices map it as a network drive, backups land on it automatically, and it sips watts compared to an old PC repurposed as a NAS.
What you need
- Raspberry Pi 4 or 5, ideally 4 GB+ RAM
- External USB 3 drive (SSD preferred over spinning disk for bus power reasons)
- Power supply rated for the drive load; a powered USB hub avoids brownouts with mechanical disks
- Raspberry Pi OS Lite flashed per [[raspberry-pi-headless-setup]]
- Wired Ethernet connection strongly recommended
Step by step
- Update the system:
sudo apt update && sudo apt full-upgrade. - Connect the drive and identify it with
lsblk; note its device name such as/dev/sda1. - Format it to ext4 if new:
sudo mkfs.ext4 /dev/sda1. Skip this if reusing a drive with data; ext4 is fastest on Linux but exFAT works if the drive also plugs into other devices. - Create a mount point and mount permanently by adding a line to
/etc/fstab:UUID=your-uuid /mnt/nas ext4 defaults,nofail 0 2. Get the UUID fromsudo blkid. Thenofailoption lets the Pi boot without the drive attached. - Mount now with
sudo mount -aand create a shared folder:sudo mkdir -p /mnt/nas/sharethen set ownership to your user. - Install Samba:
sudo apt install samba, then edit/etc/samba/smb.confand append a share block definingpath = /mnt/nas/share,browseable = yes,read only = no, andvalid users = youruser. - Add your user to Samba's password store with
sudo smbpasswd -a youruser, then restart withsudo systemctl restart smbd. - From another computer, connect to
\\pi-server\share(Windows) orsmb://pi-server/share(Mac/Linux) and enter your credentials; copy a test file in both directions. - Optional hardening: enable Samba's recycle-bin style VFS module so deletions go to a trash folder instead of vanishing.
Common mistakes
- Relying on Wi-Fi; gigabit Ethernet roughly doubles throughput and removes dropouts.
- Mounting by device name in fstab instead of UUID; device letters shuffle when drives are added.
- Forgetting
nofail, leaving the Pi stuck at boot when the drive is unplugged. - Using an unpowered hub with a spinning HDD that draws more current than USB ports supply.
Related guides
This server hosts media for [[raspberry-pi-media-center-kodi]] and backup images from [[raspberry-pi-backup-restore-sd-card]]. It shares infrastructure with any headless box built via [[raspberry-pi-headless-setup]].