Skip to content
GEEKnodes

Raspberry Pi

Raspberry Pi Home NAS: Drives, Samba and Backups

Turn a Raspberry Pi into a reliable home NAS: which drives to choose, how to power them, mount them, share them with Samba and automate backups.

A NAS is a drive connected to your home network that all your devices access. Commercial ones cost quite a bit, but a Raspberry Pi 4 or 5 with one or two USB drives does the same for home use. In this guide we build the whole NAS: drive choice, power, mounting, shared folders and automatic backups.

In short

  • A Raspberry Pi 4 or 5 over Ethernet reaches about 100 MB/s, the Gigabit network limit.
  • The weak point is power: 3.5” drives need their own supply, and several 2.5” ones need a powered USB hub.
  • Format drives as ext4 and mount them by UUID with the nofail option.
  • To start, a nightly rsync copy between two drives protects more than RAID 1.
  • No NAS is a backup on its own: keep one copy off-site.

Is it worth it versus a commercial NAS?

It depends on what you want. The Raspberry Pi wins on price and flexibility; a commercial NAS on convenience and drive bays.

Raspberry Pi NAS2-bay commercial NAS
Price without drivesLow (board, supply, case)Medium or high
Power drawVery low, a few wattsSomewhat higher
DrivesUSB or a SATA HATInternal SATA bays
SetupYou configure itWizard and web panel
Other usesDocker, Pi-hole, VPN…Maker’s apps

If you like learning and want a server that does more, the Pi is a great option. If you just want to plug in and forget, a commercial NAS is easier.

What you need

  1. A Raspberry Pi 4 or 5. The Pi 5 is faster and has PCIe; compare models in which Raspberry Pi to buy.
  2. The official power supply (27 W for the Pi 5, 15 W for the Pi 4).
  3. One or two external USB 3.0 drives.
  4. An Ethernet cable: over Wi-Fi speed drops a lot.
  5. A static IP and 64-bit Raspberry Pi OS Lite.

Which drives should I choose?

TypeProsCons
Portable 2.5” HDDUSB powered, cheap per TBLimited capacity, somewhat slow
3.5” HDD in powered enclosureLots of capacity at the best priceNoisier, draws more, bulkier
SSD (SATA or NVMe in USB enclosure)Fast, silent, low powerExpensive per TB

For photos, documents and backups, an HDD is enough: the Gigabit network limits speed before the drive does. To work out how long your library will take to copy, use the transfer time calculator.

Three drive types for the NAS: 2.5 inch HDD cheap per TB, 3.5 inch HDD with own power supply and fast silent SSD
Each drive type has its own balance of price, power and noise.

Power: the most common failure

If a drive disconnects on its own or clicks on startup, it is almost always lack of current. The official USB port limits are:

Board and supplyTotal USB current
Pi 5 with official 27 W supply (5 A)1.6 A
Pi 5 with 3 A supply600 mA
Pi 4 with official 15 W supply1.2 A

A 2.5” HDD can draw close to 1 A when spinning up. So:

  • With a single 2.5” drive and the official supply it usually suffices.
  • With two or more, use a powered USB hub.
  • 3.5” drives always have their own supply.

On the Pi 5 there is an alternative: a SATA HAT over PCIe, which connects SATA drives directly and powers them from a separate supply.

NAS diagram: the board with its 27 W supply, two drives on a powered USB hub and an Ethernet connection to the router, which serves the PC and phone
With several drives, a powered hub prevents dropouts from lack of current.

Step 1: format the drive as ext4

Connect the drive and find it:

lsblk -f

Suppose it is /dev/sda. Formatting erases everything, so double-check the name. Create a partition and format it:

sudo parted /dev/sda --script mklabel gpt mkpart datos ext4 0% 100%
sudo mkfs.ext4 -L datos /dev/sda1

ext4 is Linux’s native system: it respects permissions and is more reliable than NTFS or exFAT on a server. To understand the differences, see file systems explained.

Step 2: mount it permanently

Get the drive’s UUID and create the mount point:

sudo blkid /dev/sda1
sudo mkdir -p /mnt/datos

Add a line to /etc/fstab with sudo nano /etc/fstab, replacing the UUID with yours:

UUID=your-uuid  /mnt/datos  ext4  defaults,noatime,nofail  0  2

nofail lets the Pi boot even if the drive is not connected. Test the line without rebooting:

sudo mount -a && df -h /mnt/datos

Step 3: share with Samba

With the drive mounted, share it on the network with Samba to see it from Windows and macOS. Installation, smb.conf, permissions and typical errors are explained step by step in Samba on Raspberry Pi. Point the share at /mnt/datos.

If you prefer to manage everything from a web panel, OpenMediaVault is a NAS system installed on Raspberry Pi OS Lite. Check its documentation for the version compatible with your system.

RAID 1 or nightly copy?

With two drives, the temptation is RAID 1 (mirror): both store the same and if one dies the other carries on. If you do not know the levels, read RAID 0, 1, 5, 6 and 10 explained.

The problem: the mirror also copies mistakes. If you delete a folder by accident or ransomware encrypts your files, they vanish from both drives instantly. Also, RAID over USB is more fragile: a momentary disconnect can mark a drive as failed.

At home, a main drive and a backup drive synced every night is more useful:

RAID 1Nightly rsync copy
If a drive diesKeeps workingYou recover last night’s state
If you delete a fileLost on bothYou have it in the copy
ComplexityMedium (mdadm)Low
Usable capacityOne drive’sOne drive’s
Comparison: with RAID 1 a deleted file disappears from both drives; with a nightly copy the backup drive keeps it and it can be recovered
The mirror protects against drive failure; the nightly copy also against your mistakes.

Step 4: automatic copies with rsync

Mount the second drive at /mnt/copia the same way. This command copies everything new or changed:

sudo rsync -a /mnt/datos/ /mnt/copia/

Without the --delete option, what you delete on the main drive stays in the copy, which is exactly what we want. Schedule it every night at 3:00 with sudo crontab -e:

0 3 * * * rsync -a /mnt/datos/ /mnt/copia/ >> /var/log/copia-nas.log 2>&1

More examples in cron on Raspberry Pi. And remember the 3-2-1 rule: keep a third copy off-site, for example a drive you rotate at a relative’s house.

Look after the drives

  • Monitor health with SMART: sudo apt install smartmontools and sudo smartctl -a -d sat /dev/sda. Some USB enclosures do not allow it.
  • Ventilation: drives should not be stacked or covered.
  • A small UPS keeps a power cut from corrupting the file system.

Total draw is usually 5 to 15 W depending on drives. To know the yearly cost, use the electricity cost calculator.

Frequently asked questions

Can I access the NAS from outside home? Yes, and the safest way is via VPN, without exposing Samba to the internet. With Tailscale on Raspberry Pi you have it in minutes without touching the router.

Can it do Time Machine backups? Yes. Samba can announce a Time Machine compatible share with the options vfs objects = fruit streams_xattr and fruit:time machine = yes. More on Time Machine in the complete Time Machine guide.

What if I want a cloud with phone apps? Then you want Nextcloud on Raspberry Pi, which can store its data on the same NAS drive.

Can drives sleep when idle? Many external HDDs sleep on their own. If yours does not, tools like hdparm or hd-idle force it. Each wake-up takes a few seconds.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor