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
nofailoption.- 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 NAS | 2-bay commercial NAS | |
|---|---|---|
| Price without drives | Low (board, supply, case) | Medium or high |
| Power draw | Very low, a few watts | Somewhat higher |
| Drives | USB or a SATA HAT | Internal SATA bays |
| Setup | You configure it | Wizard and web panel |
| Other uses | Docker, 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
- A Raspberry Pi 4 or 5. The Pi 5 is faster and has PCIe; compare models in which Raspberry Pi to buy.
- The official power supply (27 W for the Pi 5, 15 W for the Pi 4).
- One or two external USB 3.0 drives.
- An Ethernet cable: over Wi-Fi speed drops a lot.
- A static IP and 64-bit Raspberry Pi OS Lite.
Which drives should I choose?
| Type | Pros | Cons |
|---|---|---|
| Portable 2.5” HDD | USB powered, cheap per TB | Limited capacity, somewhat slow |
| 3.5” HDD in powered enclosure | Lots of capacity at the best price | Noisier, draws more, bulkier |
| SSD (SATA or NVMe in USB enclosure) | Fast, silent, low power | Expensive 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.

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 supply | Total USB current |
|---|---|
| Pi 5 with official 27 W supply (5 A) | 1.6 A |
| Pi 5 with 3 A supply | 600 mA |
| Pi 4 with official 15 W supply | 1.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.

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 1 | Nightly rsync copy | |
|---|---|---|
| If a drive dies | Keeps working | You recover last night’s state |
| If you delete a file | Lost on both | You have it in the copy |
| Complexity | Medium (mdadm) | Low |
| Usable capacity | One drive’s | One drive’s |

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 smartmontoolsandsudo 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.



