Build it step by step
0 of 7 doneFit the HAT and SSD
With the Pi off.
Boot and check lsblk
SSD appears as nvme0n1.
Format and mount
With the UUID in fstab.
Install Samba
Add the group and user.
Add the share
Edit smb.conf.
Connect from a PC
Map the network drive.
Set up a backup
rsync to a second drive.
How do you build a pi network file server?
A Pi 5 with an NVMe SSD shares files to every device at home with Samba. You need Raspberry Pi 5, NVMe SSD 256 GB (M.2 2230/2242), Raspberry Pi M.2 HAT+, Raspberry Pi 27 W USB-C power supply, SanDisk microSD card 32 GB (A1, Class 10) and Raspberry Pi 5 Active Cooler. It takes 7 steps and about 120 minutes.
- Level
- Beginner
- Time
- About 120 min
- Parts
- 6
Wiring
| From | To | Why |
|---|---|---|
| M.2 HAT+ | Pi 5 PCIe connector and the 40-pin header, on standoffs | NVMe link |
| NVMe SSD | M.2 HAT+ slot, secured with the screw | Storage |
| Active cooler | Pi 5 cooler header | Cooling |
| Power supply | Pi 5 USB-C, the official 27 W model | Power |
| Network cable | Pi Ethernet port into your router | Network |
Code
Samba lets Windows, Mac, Linux and phones see a folder on the Pi as a network drive. The SSD on the M.2 HAT+ is much faster than an SD card and does not wear out as fast, so it is the right place for shared files; keep the SD card for the operating system only. Format commands erase everything, so check the drive name with lsblk before running mkfs. Samba users need their own Samba password, set with smbpasswd, and access is limited to members of the nasusers group. A NAS is not a backup: if the SSD fails or you delete a file, it is gone, so copy important folders to a second drive with rsync on a schedule, and keep one copy away from the house. Use the router to give the Pi a fixed address, do not forward any ports to it from the internet, and keep the system updated with sudo apt update and sudo apt upgrade. The PCIe link is sold as supported at Gen 2 speeds, and Gen 3 can be turned on in config.txt at your own risk. Raspberry Pi OS (Bookworm or newer) with Python 3.
# Commands on the Pi (run line by line, read what each one does first) sudo apt update && sudo apt install samba # Find the SSD, then format it. The next line ERASES the whole drive, so check the name with lsblk first. lsblk sudo mkfs.ext4 /dev/nvme0n1 # Mount it at boot using its UUID (blkid shows it) sudo mkdir -p /srv/nas sudo blkid /dev/nvme0n1 # add this line to /etc/fstab, with your own UUID: # UUID=PUT-YOUR-UUID-HERE /srv/nas ext4 defaults,noatime 0 2 sudo mount -a # A group, a folder and a user (smbpasswd asks you to type the password; it is not stored in any file you write) sudo groupadd nasusers sudo mkdir -p /srv/nas/family sudo chgrp nasusers /srv/nas/family sudo chmod 2770 /srv/nas/family sudo usermod -aG nasusers YOUR_USERNAME sudo smbpasswd -a YOUR_USERNAME # Add to the end of /etc/samba/smb.conf, then restart with: sudo systemctl restart smbd [family] path = /srv/nas/family read only = no valid users = @nasusers create mask = 0660 directory mask = 0770
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| lsblk | Shows the SSD |
| After reboot | /srv/nas still mounted |
| From a PC | Can read and write the share |
| Wrong password | Refused |
If it does not work
SSD not seen
Reseat it and check the ribbon and the PCIe setting.
Access denied
Check group membership and the smbpasswd user.
Share not found
Check smb.conf and restart smbd.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the pi network file server?
Raspberry Pi 5, NVMe SSD 256 GB (M.2 2230/2242), Raspberry Pi M.2 HAT+, Raspberry Pi 27 W USB-C power supply, SanDisk microSD card 32 GB (A1, Class 10) and Raspberry Pi 5 Active Cooler.
How long does the pi network file server take to build?
About 120 minutes for a beginner maker, in 7 steps.
How do I know the pi network file server works?
lsblk: Shows the SSD. After reboot: /srv/nas still mounted. From a PC: Can read and write the share.
SSD not seen: what should I check?
Reseat it and check the ribbon and the PCIe setting.
Access denied: what should I check?
Check group membership and the smbpasswd user.
Share not found: what should I check?
Check smb.conf and restart smbd.
