Guide · Storage · ~15 min read

Server racks in a data center corridor
Photo by Brett Sayles on Pexels

How to build a DIY NAS at home (beginner-friendly)

A Network Attached Storage box is just a small computer on your home network that shares folders to your PCs, TVs, and phones — usually filled with hard drives. You can buy a ready-made Synology or QNAP, or build your own for less money and more flexibility. This guide walks through drives, RAID types, TrueNAS vs plain Ubuntu, and the bash commands you need on a Linux path.

What is a NAS, really?

Think of it as a always-on file server in a closet. You copy movies, backups, and photos to it over Wi‑Fi or Ethernet. Unlike an external USB drive plugged into one PC, everyone on the LAN can reach it. A DIY NAS is typically an old desktop, a mini PC, or a small server board with several internal hard drives and a simple operating system focused on storage.

What you need (hardware checklist)

RAID types explained (without the jargon trap)

RAID is not a backup. It protects you from one failed disk in the array, not from ransomware, accidental deletes, or your house flooding. You still want backups (another NAS, cloud, or cold spare drive off-site).

Manufacturers quote RAID levels with numbers. Here is what home builders actually choose:

Common RAID and ZFS layouts for home NAS
NameAlso calledIn plain EnglishGood forWatch out
JBODJust a Bunch Of DisksNo redundancy — one drive per folder or merged volume.Maximum capacity, simple setupAny failure loses that drive’s data
RAID 1MirrorTwo (or more) identical copies of the same data.Survives one drive failure (in a 2-drive mirror)Uses 50% of raw capacity
RAID 5Striped + parityData spread across 3+ drives with one parity block.Good balance of space and safety for home NASRebuilds are slow; risky if another drive dies during rebuild
RAID 6Double parityLike RAID 5 but tolerates two drive failures.Safer for large arrays (6+ drives)More capacity overhead than RAID 5
RAID 10Mirror + stripePairs of mirrors, then striped (needs 4+ drives, even count).Fast reads/writes, survives one failure per mirror pairExpensive in drives — 50% capacity loss
ZFS mirrorZFS (not classic RAID)Two drives hold the same data; managed by ZFS (TrueNAS default).Checksumming catches silent bit rot; easy in TrueNASNeeds ZFS-aware OS (TrueNAS, Ubuntu + ZFS tools)
ZFS RAIDZ1ZFS RAID-5 equivalentSingle parity across 3+ drives.Flexible snapshots & scrubbingUse ECC RAM if possible; learn ZFS basics first

TrueNAS vs plain Ubuntu — which should you pick?

Both are valid. The choice is really “appliance vs general-purpose Linux.”

TrueNAS SCALE (or TrueNAS Core)

Plain Ubuntu Server (or Debian)

Quick comparison
TrueNASUbuntu Server
Best forSet-and-forget file serverTinkerers & multi-purpose homelab
RAID / poolsZFS via GUImdadm, ZFS, or mergerfs — your call
Learning curveLowerHigher
AppsOfficial apps + Docker (SCALE)Anything in the Linux ecosystem
CLIOptionalRequired for setup & fixes

Path A — TrueNAS in brief

  1. Download TrueNAS SCALE from the official site and write the installer to a USB stick (Balena Etcher or dd).
  2. Boot the NAS PC from USB; install TrueNAS onto your boot SSD, not your data drives.
  3. In the web UI (https:// your-nas-ip), use Storage → Create pool and pick Mirror (2 drives) or RAIDZ1 (3+ drives).
  4. Create a dataset (e.g. pool/home), then Shares → SMB for Windows/macOS access.
  5. Schedule a scrub monthly and enable email/Discord alerts for failed drives.

No bash required for day-to-day use — that is the point.

Path B — Ubuntu Server with bash (mdadm + ext4)

Below assumes Ubuntu Server 24.04 LTS, three empty data disks (/dev/sdb, /dev/sdc, /dev/sdd), and a RAID 5 array. Replace device names with yours. The install will destroy data on those disks.

1. See what the system detects

lsblk -o NAME,SIZE,TYPE,FSTYPE,MODEL,MOUNTPOINT

Unmounted disks you plan to use show no MOUNTPOINT. Note exact names — mixing them up is painful.

2. Install RAID tools

sudo apt update
sudo apt install -y mdadm

3. Create a RAID 5 array (example)

# Creates /dev/md0 from three drives — confirm names first!
sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd

Answer prompts; the installer may ask about updating /etc/mdadm/mdadm.conf — say yes.

4. Check array status

cat /proc/mdstat
sudo mdadm --detail /dev/md0

5. Format and mount

sudo mkfs.ext4 -L nas-data /dev/md0
sudo mkdir -p /mnt/nas
sudo mount /dev/md0 /mnt/nas
df -h /mnt/nas

6. Auto-mount after reboot

# Get the RAID UUID
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u

echo '/dev/md0 /mnt/nas ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab
sudo mount -a

7. Share folders with Samba (Windows / macOS)

sudo apt install -y samba
sudo mkdir -p /mnt/nas/shared
sudo chown -R $USER:$USER /mnt/nas/shared

Add a share block to /etc/samba/smb.conf:

[shared]
   path = /mnt/nas/shared
   browseable = yes
   read only = no
   guest ok = no
   valid users = your_linux_username
sudo smbpasswd -a your_linux_username
sudo systemctl restart smbd

From Windows: \\nas-ip\shared — from macOS: Finder → Go → Connect to Server → smb://nas-ip/shared.

Optional — ZFS on Ubuntu (TrueNAS-like pools)

If you want checksums and snapshots on Ubuntu:

sudo apt install -y zfsutils-linux
# Mirror (RAID 1) example with two drives:
sudo zpool create tank mirror /dev/sdb /dev/sdc
sudo zfs create tank/media
sudo zfs set compression=lz4 tank/media
zfs list

Point Samba at /tank/media instead of /mnt/nas. Use zpool status and zpool scrub tank for health checks.

Replacing a failed drive (mdadm)

# Mark failed (if not already):
sudo mdadm /dev/md0 --fail /dev/sdb
sudo mdadm /dev/md0 --remove /dev/sdb
# After physically swapping the drive:
sudo mdadm /dev/md0 --add /dev/sdb
cat /proc/mdstat   # watch resync

Security & habits worth adopting

Summary

Pick drives that match your capacity and budget (NAS-rated HDDs, 8 TB+ for multi-bay builds), choose RAID 1 / RAIDZ1 / RAID 5 for redundancy, and decide whether you want TrueNAS’s GUI or Ubuntu’s flexibility. RAID keeps the server running when a disk dies; backups keep your files safe when you delete the wrong folder or get hit by malware.

When you are ready to buy disks, compare prices on hwprice — start with the NAS build quick pick.

← Back to price comparison · About hwprice · Local LLM guide

Comments

Questions, corrections, or your own NAS build notes? Join the discussion below.

Loading comments…