Build a Raspberry Pi 5 NAS with an NVMe SSD and Samba

Raspberry Pi NVMe SSD

Level: Intermediate  ·  Time: 1 hour  ·  Board: Raspberry Pi 5

A NAS (network-attached storage) is a drive that every computer at home can reach over the network: a shared place for documents, photos and project files. A Raspberry Pi 5 with an NVMe SSD makes a small, silent one that uses a few watts. Samba is the software that speaks SMB, the file-sharing protocol Windows, macOS and Linux all understand out of the box.

What you need

You'll also need an Ethernet cable. The Pi 5 has Gigabit Ethernet, which is much faster and steadier than Wi-Fi for moving large files.

In this build the operating system stays on the microSD card and the whole SSD is used for shared files. That keeps your data separate from the system: if you ever reinstall the OS, the SSD and everything on it is untouched.

1. Install Raspberry Pi OS Lite

Use Raspberry Pi Imager to write Raspberry Pi OS Lite (64-bit) to the microSD card. In the OS customisation screen, set the hostname to nas, create a user and password, and turn on SSH. Connect the Pi to your router with the Ethernet cable, power it on and log in from your computer:

ssh yourname@nas.local

Update everything, including the bootloader firmware:

sudo apt update && sudo apt full-upgrade -y
sudo rpi-eeprom-update -a
sudo reboot

In your router, add a DHCP reservation for the Pi so its address never changes.

2. Fit the SSD

Power off, fit the M.2 HAT+ and the SSD as described in our NVMe guide (steps 2 and 3), then boot from the microSD card again. Check that the drive is detected:

lsblk

You should see nvme0n1 with its full size. If not, recheck the ribbon cable orientation.

3. Format the SSD

This erases everything on the SSD. Make sure nvme0n1 really is the drive you want to use, then create one partition that fills it and format it as ext4 with the label nas:

sudo parted /dev/nvme0n1 --script mklabel gpt mkpart nas ext4 0% 100%
sudo mkfs.ext4 -L nas /dev/nvme0n1p1

4. Mount it at startup

Create a mount point and find the partition's UUID, a unique ID that doesn't change even if device names do:

sudo mkdir -p /srv/nas
sudo blkid /dev/nvme0n1p1

Open the file system table with sudo nano /etc/fstab and add this line at the end, replacing the UUID with the one blkid printed:

UUID=your-uuid-here  /srv/nas  ext4  defaults,noatime,nofail  0  2

noatime saves needless writes every time a file is read, and nofail lets the Pi still boot if the SSD is ever missing. Save, then mount it and check:

sudo systemctl daemon-reload
sudo mount -a
df -h /srv/nas

Create a folder to share and make your user its owner:

sudo mkdir /srv/nas/shared
sudo chown yourname:yourname /srv/nas/shared

5. Install and configure Samba

sudo apt install -y samba

If the installer asks whether to modify smb.conf to use WINS settings from DHCP, choose No. Then open the configuration file:

sudo nano /etc/samba/smb.conf

Add this share at the very end of the file:

[shared]
   path = /srv/nas/shared
   read only = no
   browseable = yes
   valid users = yourname
   create mask = 0664
   directory mask = 0775

Samba keeps its own passwords, separate from your Linux login. Set one for your user (it can be the same as your login password), check the configuration for mistakes, and restart Samba:

sudo smbpasswd -a yourname
testparm
sudo systemctl restart smbd

testparm should print Loaded services file OK. followed by your settings, including the [shared] section.

6. Connect from your computers

  • Windows: in File Explorer, type \\nas.local\shared in the address bar and sign in with your Samba user and password. To give it a drive letter, right-click This PC → Map network drive and use the same address.
  • macOS: in Finder, choose Go → Connect to Server, enter smb://nas.local/shared and sign in as a Registered User.
  • Linux: in the file manager's location bar, enter smb://nas.local/shared.

If nas.local doesn't resolve, use the Pi's IP address from your router instead, for example \\192.168.1.50\shared.

7. Keep an eye on the drive

Check free space with df -h /srv/nas. NVMe drives also report their own health: install smartmontools and look at the wear and error counters now and then:

sudo apt install -y smartmontools
sudo smartctl -a /dev/nvme0

The lines to watch are Percentage Used, which climbs slowly towards 100% over the drive's life, and Media and Data Integrity Errors, which should stay at 0.

Tip: A NAS with one drive is a convenient shared folder, not a backup: if the SSD fails, or a file is deleted by mistake, it's gone. Keep a second copy of anything important on another drive or in the cloud. On the Pi, rsync -a /srv/nas/shared/ /media/backup/shared/ copies everything to a USB drive mounted at /media/backup, and only transfers what changed since the last run.

Next steps

  • Point Home Assistant at your new share under Settings → System → Storage → Add network storage and use it as a backup location.
  • Reach your files safely while you're away with your own WireGuard VPN. Never forward the SMB port on your router.