The NASberry Pi

7 minute read

A What Now?

I wanted to try creating my own NAS using a Raspberry Pi and NVMe drives. This post goes over what I have did to get it up and running.

(The article name come from a comment in a video I talk about in the last section but thank you Tristan Holley.)

The Setup

I set up a Raspberry Pi 5 so that I could SSH into it. This involved writing Raspberry Pi OS Lite to a micro SD card and then configuring things with the Pi connected to a monitor and keyboard. I believe that you can do it all before even powering on a Pi with the Raspberry Pi Imager but I’ve never had much luck running it on my not-very-mainstream Linux machine.

Once I had a Pi with updated software, a fixed IP address, and SSH access I followed Pimoroni’s instructions for getting the NVME Base Duo set up.

After checking that the Pi could see the drives via lsblk I followed the instructions in an article from The MagPi about building a Raspberry Pi NAS. Go from step 5 and remember that rather than the drives being something like /dev/sda they will be something like /dev/nmve0n1 and /dev/nvme1n1 and in step 6 something like /dev/nvme0n1p1 and /dev/nvme1n1p1.

Note that the last command in step 7 is actually a single line:

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

It is worth noting here that I had some problems which probably stemmed from me copying and pasting the above command which ran it as two commands. Don’t copy and paste in a hurry!

When I rebooted at the end of step 7 my Pi would not start up. I had to reconnect the NVMe Base Duo and plug the micro SD card into my computer to comment out the lines added to /etc/fstab and to /etc/mdadm/mdadm.conf. The Pi then booted up again and I could edit the files.

However the raid drive now seemed to be /dev/md127 rather than the expected dev/md0 so my /etc/fstab file contains:

/dev/md127 /mnt/raid1/ ext4 defaults,noatime 0 1

And where the /etc/mdadm/mdadm.conf had contained ARRAY /dev/md0 metadata=1.2 name=pi-nas:0 UUID=09326e24:1a53bbf2:b078a125:04473797, after running sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf as a single line it now contained ARRAY /dev/md/pi-nas:0 metadata=1.2 name=pi-nas:0 UUID=09326e24:1a53bbf2:b078a125:04473797.

I could rename the array from md127 back to md0 but I don’t think it is worth it.

Anyway, the Pi was now set up with a RAID-1 drive using the two NVMe drives. I plugged it into a UPS and was ready to add some functionality and data to it.

Migrating The Data

My existing NAS has two shares on it: one for media for Plex and one for file storage. Both are configured with NFS access so on the Pi I could run sudo mount -t nfs 192.168.10.127:/nfs/Media /mnt/mycloud/media and sudo mount -t nfs 192.168.10.127:/nfs/Files /mnt/mycloud/files to mount the two shares. It was then easy to copy the data over to the new RAID drive.

Plex

Setting up a Plex server on a Pi is really easy and there are full details like this which are widely available.

I didn’t try to migrate the metadata from my old NAS over (partly because I had no idea how to access it) but setting up a new Plex server and adding libraries to it is a pretty trivial task.

File Sharing

There are various ways to share files between computers such as SMB/CIFS (Samba) and NFS and the article used to set up the RAID covers adding Samba shares so that it what I went with. It also helps that the Files application on iOS supports Samba shares so I can connect to the shared folders from my mobile devices (when I am on my home network) too.

Of course, since SSH is turned on, files can be transferred via the scp command too.

Pi-hole

I have been meaning to set up Pi-hole for a very long time. Now that I have an always-on Pi it seemed an ideal time to set it up and it was a trivial process.

One thing to note is that the standard Pi-hole configuration will block some things you might not want blocking and things that are not terribly obviously related to Pi-hole. For example, I thought that the iOS YouTube app was just having weird issues with my watch history but it was Pi-hole blocking it. There are some things you might want to whitelist here.

The Future?

I am not currently sure what else I want to run on this Pi but for now I am going to see how things work out with it as my Plex media server, my Pi-hole and a general file store. My old NAS has been unplugged and hopefully the next step will be to securely wipe the drives and then recycle them. I think these are the last spinning disks I used in any device and considering that my first hard drive was a 30MB one for an Amiga 1500 back in 1992 it is an end of an era but HDDs feel like very old technology now.

The one thing I do wish I had however is a case of some sort to keep some dust off the Pi but we’ll see how it goes and maybe the Active Cooler I have fitted on the Pi will deal with that itself.

The Background Story

For those of you who want to know how I got to the point where I wanted to create a NAS using a Raspberry Pi, please read on…

My first NAS was a Drobo which I bought as a simple to use RAID box which could also support drives of different capacities. I largely wanted to store media files I wanted to stream to my Apple TVs but it was also useful for local backups. That all went beautifully until I had replaced a failed drive and, during the setup of the replacement drive, another one failed (apparently this was not uncommon and was due to the extra load and heat generated during this process). Despite the Drobo containing four hard drives in total, several of my media files were corrupted and lost and because Drobo used a proprietary RAID configuration, data recovery was not simple.

I replaced the Drobo with a Western Digital My Cloud EX2 Ultra which meant that I could configure it as a RAID 1 device (the data is duplicated over two hard drives) and I could also use it as a Plex media server. For security reasons I didn’t do much more with it than that… I didn’t use it outside of my home network or run any of the other server services it offered. Unfortunately drives seemed to regularly fail in it (again probably due to heat) and when this happened recently I decided to look into what some other options were.

Using solid-state drives (SSDs) seemed like a far better alternative to using a traditional hard disk drives (HDDs) at this point and now that I have moved back to buying physical media my storage requirements are greatly reduced and because of streaming and DVDs and Blu-rays I only have about 700GB of data on my NAS.

For once the algorithms worked in my favour and YouTube managed to recommend “The ULTIMATE Raspberry Pi 5 NAS” to me (and the title of this post was stolen from a comment on that video by Tristan Holley). However a multi-drive solution was a bit excessive for what I wanted (and expensive since I just wanted to try something, not commit a huge financial investment in it) That resulted in me doing a bit more digging and finding an old MagPi article about building a Raspberry Pi NAS. That covered the drive setup and configuration but I wasn’t overly keen on using external drives.

I decided to take a look at Pimoroni’s web site to see if they sold anything related to what I wanted to do and struck gold… They have an extension board for the Raspberry Pi 5, the NVMe Base Duo, which can be populated with one or two NVMe drives. Even better, I had two 1TB Samsung SSD 980 PRO drives and a Raspberry Pi 5 so I just needed to buy the board and I also decided to pick up an Active Cooler for the Pi. So, for about £35 I could try out building a NAS on a Pi.

Updated: