· 9 min read ·

Raspberry Pi NAS: How to Build One in 2026, Step by Step

A Raspberry Pi can be a quiet, low-power NAS for the cost of a board, a power supply and a drive. This guide walks through the parts, the choices that matter, a working Samba share and the two things most builds skip: a backup plan and a way to reach the NAS from outside your home.

What is a Raspberry Pi NAS?

A Raspberry Pi NAS is a Raspberry Pi running file-sharing software with an external drive attached, so every device on your network can store and open files from one place. To build one you need a Raspberry Pi 4 or 5, a suitable power supply, an SD card for the operating system, a separate drive for your files, and software such as Samba.

Raspberry Pi's own NAS tutorial uses a Raspberry Pi 4 with 8 GB of RAM, Raspberry Pi OS Lite and external USB storage, and notes that a faster Pi saves data faster. This guide follows the same approach and adds the practical details around power, drives and backups. If you are still choosing between programs, start with our Raspberry Pi NAS software comparison; this post is about building the box.


What do you need to build a Raspberry Pi NAS?

PartWhat to chooseWhy it matters
BoardRaspberry Pi 4 or Pi 5, 4 GB RAM or moreBoth have Gigabit Ethernet and USB 3.0
Power supplyOfficial supply for your model; 27 W (5 V / 5 A) for a Pi 5Drives draw from the Pi's USB power budget
Boot mediamicroSD card, or an NVMe drive on a Pi 5Holds only the operating system
Data driveUSB SSD, or NVMe on a Pi 5 with an M.2 HAT+Holds your files, separate from the OS
Cable and caseEthernet cable, case with coolingWired network is faster and steadier than Wi-Fi
Backup driveA second drive, or an off-site copyRAID is not a backup

Prices change often and differ by country, so check current listings rather than relying on a number here. If you already own a Pi, a drive and a cable, the extra spend can be close to nothing.


Should you build it on a Pi 4 or a Pi 5?

For network speed there is little difference, because both boards have one Gigabit Ethernet port. The differences are in how you attach storage and how much USB power is available.

FeatureRaspberry Pi 4Raspberry Pi 5
NetworkGigabit EthernetGigabit Ethernet
Fast storageUSB 3.0 drivesUSB 3.0, or NVMe through the M.2 HAT+
NVMe linkNoneSingle PCIe 2.0 lane, 500 MB/s peak
Power for USB drivesOfficial 5 V / 3 A supply600 mA by default, 1.6 A with the 27 W supply

The M.2 HAT+ connects an NVMe drive to the Pi 5's PCIe 2.0 interface, with a 500 MB/s peak transfer rate and support for 2230 and 2242 drives. Because a single Gigabit port tops out below that, NVMe mainly makes boot, small-file work and apps feel faster rather than raising file-copy speed over the network.

⚠️

Power the drive properly. Raspberry Pi's 27 W power supply brief says the Pi 5 raises its USB current limit from a default 600 mA to 1.6 A when it detects that supply. A bus-powered hard drive that spins up and drops off the bus is usually a power problem, so use the right supply, a self-powered enclosure or a powered USB hub.


How do you build a Raspberry Pi NAS step by step?

1. Install Raspberry Pi OS Lite

Use Raspberry Pi Imager to write Raspberry Pi OS Lite (64-bit) to the SD card. In the Imager settings, set a hostname such as pinas, create a user and enable SSH. Lite has no desktop, which leaves more memory for file sharing. Boot the Pi on a wired network connection and log in over SSH.

sudo apt update
sudo apt full-upgrade -y
sudo reboot

2. Attach and format the data drive

Plug the drive into a blue USB 3.0 port and find it with lsblk. The commands below assume the drive shows up as /dev/sda with one partition, /dev/sda1. Formatting erases everything on the drive, so check the device name twice before you run the second command.

lsblk -f
sudo mkfs.ext4 -L nasdata /dev/sda1
sudo mkdir -p /mnt/nas

3. Mount it automatically at boot

Mount by UUID, not by /dev/sda1, because device names can change between boots. The nofail option stops a missing drive from blocking startup.

sudo blkid /dev/sda1
# copy the UUID, then add a line to /etc/fstab:
echo 'UUID=YOUR-UUID-HERE /mnt/nas ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab
sudo mount -a
sudo chown -R "$USER":"$USER" /mnt/nas
df -h /mnt/nas

4. Share it with Samba

Samba lets Windows, macOS, Linux and most phones open the share. Install it, give your user a Samba password, then add a share definition to the end of /etc/samba/smb.conf.

sudo apt install samba -y
sudo smbpasswd -a "$USER"
sudo nano /etc/samba/smb.conf
[nas]
   path = /mnt/nas
   read only = no
   browseable = yes
   valid users = YOUR-USERNAME
sudo systemctl restart smbd

From Windows, open \\pinas\nas in File Explorer. On macOS, use Finder, then Go, then Connect to Server and enter smb://pinas.local/nas.

5. Test the speed and the reboot

Copy a large file to the share and watch the transfer rate. Over Gigabit Ethernet, expect results in the region of 100 MB/s from a fast drive. In Jeff Geerling's Pi 5 NAS build, Samba reached about 96 MB/s writing from a Mac, 115 MB/s from Windows and 122 MB/s reading. Then reboot the Pi and confirm the share comes back by itself.


What are the limits of a Raspberry Pi NAS?

If you need many drives, hot-swap bays or a polished app store, a dedicated NAS fits better. Our guides to Synology alternatives for home and the TrueNAS alternative explain where that point is.

How should you back up a Raspberry Pi NAS?

RAID protects against a drive failing, but it is not a second copy: a deleted or corrupted file is deleted or corrupted on every drive. CISA's 3-2-1 guidance is three copies of important files, on two types of storage media, with one copy off-site. On a Pi NAS that usually means the live drive, a second drive that you plug in or schedule a copy to, and one copy somewhere else. Our home server backup strategy guide covers the options.


How do you reach a Raspberry Pi NAS from outside your home?

A Samba share is designed for your local network and should not be exposed directly to the internet. For remote access you need an approach that does not open your router to the world. Many home internet connections also sit behind CGNAT, so inbound port forwarding is not even possible.

Tunnels and relays solve this by connecting outward from your home, which works behind CGNAT. Our guide to self-hosting without port forwarding compares the approaches. Gavety is one of them: its agent makes an outbound peer-to-peer or relay connection, so remote access works without port forwarding. It gives you file browsing in a browser, sharing links, multiple users with permissions and media streaming. It does not have file sync, calendar, contacts or office editing. Gavety's stated requirement is a Raspberry Pi 4 with 4 GB of RAM or more, or another Linux machine with at least 4 GB of RAM. See Raspberry Pi cloud storage for a setup walkthrough.

Add remote access to your Pi NAS

Keep your files on your own drive and reach them from a browser, anywhere. Start on your local network for free and add remote access when you need it.

Get started →

Free LAN tier for 1 user · $100 one-time consumer licence per device · $20 per user per year for remote access


Frequently asked questions

Can a Raspberry Pi be used as a NAS?
Yes. Raspberry Pi's own tutorial builds a NAS from a Raspberry Pi 4, Raspberry Pi OS Lite and an external USB drive, and shares it over the network. The Pi has no drive bays and one Gigabit Ethernet port, so it suits home and small-office file storage rather than heavy multi-user workloads.
Which Raspberry Pi is best for a NAS, the Pi 4 or the Pi 5?
Both have Gigabit Ethernet and two USB 3.0 ports, so network speed is similar. The Pi 5 adds a single PCIe 2.0 lane that the official M.2 HAT+ uses for an NVMe drive, and it needs the 5 V / 5 A supply to give USB drives more current. A Pi 4 with 4 GB of RAM or more is enough for a simple NAS.
Can I use the SD card as NAS storage?
It is better not to. Use the SD card (or a small boot drive) for the operating system and keep your files on a separate USB SSD, hard drive or NVMe drive. Separating the two also lets you move the drive to another machine if the Pi fails.
How fast is a Raspberry Pi NAS?
The Gigabit Ethernet port is the limit, which is roughly 125 MB/s in theory. In Jeff Geerling's Pi 5 build, Samba reached about 96 MB/s writing from a Mac, 115 MB/s from Windows and 122 MB/s reading, with SSDs on a SATA HAT. That is one build, not a guarantee for every setup.
Do I need RAID on a Raspberry Pi NAS?
Not for most home use. RAID keeps a drive failure from taking the array offline, but it is not a backup, because deleted or corrupted files are copied to every drive. CISA's 3-2-1 guidance is three copies of important files, on two types of storage media, with one copy off-site.
Can I reach my Raspberry Pi NAS from outside my home?
Yes, but a plain Samba share is meant for your local network and should not be exposed directly to the internet. Many home connections also sit behind CGNAT, which rules out port forwarding. A tunnel or relay that connects outward from your home works in that case. Gavety's agent makes an outbound connection, so remote access works without port forwarding, including behind CGNAT.
What software should I install on a Raspberry Pi NAS?
It depends on the job. Samba is the simplest way to share a drive on your home network, OpenMediaVault adds a web interface and RAID, and Gavety adds browser access, sharing links and remote access. Our Raspberry Pi NAS software comparison covers each option and what it is best for.

Sources