Build a Raspberry Pi NAS for Network File Storage

· 3 min read raspberry-pinassambastoragenetworking

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

  1. Update the system: sudo apt update && sudo apt full-upgrade.
  2. Connect the drive and identify it with lsblk; note its device name such as /dev/sda1.
  3. 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.
  4. 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 from sudo blkid. The nofail option lets the Pi boot without the drive attached.
  5. Mount now with sudo mount -a and create a shared folder: sudo mkdir -p /mnt/nas/share then set ownership to your user.
  6. Install Samba: sudo apt install samba, then edit /etc/samba/smb.conf and append a share block defining path = /mnt/nas/share, browseable = yes, read only = no, and valid users = youruser.
  7. Add your user to Samba's password store with sudo smbpasswd -a youruser, then restart with sudo systemctl restart smbd.
  8. From another computer, connect to \\pi-server\share (Windows) or smb://pi-server/share (Mac/Linux) and enter your credentials; copy a test file in both directions.
  9. 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]].