Raspberry Pi NAS Setup

What’s a NAS?

NAS stands for network attached storage, essentially an external hard drive that you don’t have to plug into, and can access the contents of over the network. Another feature that a NAS commonly has is that it’s network attached, meaning it’s not accessible from the rest of the internet. I’ve gotten around this limitation to access my Pi from the internet without port forwarding, and I’ll explain later how.

Hardware

The actual Pi used in this setup is a Raspberry Pi Model 4 with 4 GB of RAM. The hard drive I chose was this SSD, and I connected it to the Pi using this contraption and powered the whole setup using this. I could have simply used an external hard drive of some kind, and plugged it into the USB ports on the Pi, but external drives tend to be more expensive than their internal counterparts, and there would be the addition of cables to manage.

Software

Operating System

The operating system of choice for this project was the Lite edition of Raspberry Pi OS, the official 32 bit OS for the Pi. You could install a 64 bit version of Debian, as the Pi does have a 64 bit arm CPU, however that would’ve required more work on my part so I went with the easier option available from Raspberry Pi Imager. The reason specifically for Debian will become apparent soon.

NAS Management

To manage the Pi through the browser and configure all of the internals for a NAS setup in general I chose openmediavault. This was mainly due to the large number of tutorials online, and because it was a simple one-liner to install (see this). One key requirement of OMV is that it is Debian based, and to my knowledge can’t be installed on Ubuntu due to strict requirements around Debian’s packages.

Services

ZeroTier

At the time I was originally setting up the Pi, the router I had did not support static IP addresses, and rebooting the Pi sometimes caused it to change (the router I have now can, but I’m too lazy to set that up). I also didn’t want to do any port forwarding, one because I don’t know how to configure it, and two because I don’t want people trying to break into my network. My solution to all of these problems was ZeroTier. ZeroTier is not a VPN, however in my use case it acts very similarly to one. ZeroTier allows all devices on a created ZeroTier network (done through an account on the website) to be able to connect to one another as if they were on the same LAN, and the IP that they use to do so is always the same. I’ve added a bunch of my devices, including the Pi, to a network, and using either SSH or SFTP I can connect to the Pi and look at the files, or access the OMV dashboard regardless of if I’m on my home network.

Shared Folders / Users

OMV lets you create shared folders to be used with various services (SMB, FTP, etc), and users for people to login with. The only people using this server are my roommate and I, so I created new users for each of us, and added them to the same group as the default pi user. I then created three shared folders, one for each of us personally and a third for general media storage. The two individual shares have read/write permissions for each of our users, and the media share has read/write permissions for both at once.

SMB

My roommate primarily uses Windows, so on our local network I’ve set up SMB to allow both of us to connect to each of the three shares from the server. The shares for each of us individually are set non-public, and the media share is set as guest allowed. If anybody else joins our network they can see what is in the media share, but they can’t change anything.

SFTP

From my testing SMB doesn’t work when not on a local network, even with ZeroTier, so I had to find another solution to connect to the server from outside the network. My solution was SFTP using an SSH key. I’ve only configured SFTP for myself so far, but using an SSH key I’ve generated on my laptop and given to the server I can successfully access files in my personal shared folder without being on the same local network.

MiniDLNA

While I’ve heard of Plex for media servers before, it seemed far more complex than anything I would need this server to do. After a bit of research I discovered MiniDLNA, a server software that aims to be compliant with DLNA/UPnP clients (see more here). OMV conveniently has a miniDLNA plugin, so a few clicks later and I could stream media directly to any device I with VLC installed (VLC has great DLNA support).