I finished my first Raspberry Pi project last weekend. I had a few external SSDs that were collecting dust on my desk. I intended one to be a backup device for my home computers. The other was the storage for a now defunct set-top box. Following a guide from How-To Geek, I combined a Pi with the two drives to create a cheap, low power NAS.

NAS stands for Network Attached Storage. It makes it possible to backup or store files from my home devices over the network. I won't need to connect the external drive to each device anytime I want to back up or retrieve a file.

Parts

I've already mentioned the main pieces to this project - the Pi and two drives. You're going to need a few more parts.

Raspberry Pi

The Raspberry Pi 3 B+ is a neat little machine. It has four USB ports, WiFi, and HDMI output.

Unless you're buying a kit, the Pi doesn't come with an SD card or a power cable. You'll also need a mouse, keyboard, a monitor with video cable, and an ethernet cable if you aren't using WiFi.

SD Card

Depending on the version of your Pi, you'll need an SD or Micro SD card image with an OS or installer. You can buy pre-imaged cards ready to go. If you have access to an SD or Micro SD card slot. I recommend buying a blank Micro SD card and writing the OS image to the card yourself. It's a fairly simple process and there are several guides on how to do it. My laptop has an SD Slot so I purchased a Micro SD card with an adapter for less than $10.

Case

I'm not sure a case is required, but I ordered one to protect it from dust. I looked at a few different cases and decided on a Miuzei case like this one. I liked the look of the smoky gray/black option so I picked that one. The one I snagged was a bit cheaper as it didn't come with an SD card. It comes with a fan and three heat sinks. Those probably aren't necessary for this project, but I installed them since they were available. I did have some trouble getting the bottom heat sink to line up with the case and had to do a little rework. The fan wires were difficult to get into the case. I tried three fan orientations before stuffing them in and hoping for the best. So far I haven't had any issues with it.

Drives

You should be able to use any external USB drives that you have available or want to get. Mine are older so they are bulkier and have their own power sources. Once they stop working, I'll replace them with something smaller and more power efficient.

Changes

The How-To Geek guide is great. I didn't run into any major problems during the setup. There was one minor thing different in my Samba config. I also made a change to how the disks are mounted.

Samba Config

There wasn't a line for security = user in the authentication section of my Samba config. I didn't dig into it very much and settled for adding the line and seeing what happened. Everything's working so far.

Disk Labels

I'm using the two disk option with rsync to back up the main drive to the secondary drive daily. I gave each of the disk partitions labels when I formatted them to NTFS. I labeled one drive as NASMain and the other as NASBackup.

I found out during this project that the drives don't always register with the same identifier on each boot. That means my main drive that was /dev/sda when I configured everything could be /dev/sdb after a reboot. It's possible for the drives to switch uses if the Pi had an issue or lost power during a storm. If that happens, I could lose files during the next rsync execution.

I thought that I could script out some Python to investigate the disk label and use that to make sure they were mounted correctly each start up. After some quick research, I found out about udev and /dev/disk/by-label. In that directory, there are links to the devices using the NASMain and NASBackup labels. No extra work needed by me. I updated /etc/fstab to have these lines.

/dev/disk/by-label/NASMain /media/USBHDD1 auto noatime 0 0
/dev/disk/by-label/NASBackup /media/USBHDD2 auto noatime 0 0

Wrap Up

The Raspberry Pi is very easy to work with and I'm glad to have those drives doing something other than holding my desk down. I've already got a few more ideas brewing for future Pi projects.