Skip to main content
Building my DIY NAS

Building my DIY NAS

·1845 words·9 mins·
diy hardware self-hosted linux
Table of Contents

After reworking my backup concept and my expected growth of data I came to the conclusion that I need a NAS. So I decided to give my good old Synology DS211j from 2011(!) a shoot (again). Turns out that it was indeed still working, and I was happy to save time and money. Unfortunately, the NAS was extremely slow due to its weak hardware. Updating the DSM software itself took two days and the web UI was sluggish. Overall, the file operation performance was also not exciting. Finally, there is a reason to spend money on new stuff 🙈

Before shopping, I went back to the drawing board thinking about my needs and use cases for a proper replacement.

Requirements
#

These requirements come in no specific order as all are must haves!

  1. Enough storage
  2. Drive failure does not lead to data loss
  3. Manageable via web UI
  4. Syncthing must run (highly recommended masterpiece of software!)
  5. Enough performance for some home lab stuff
  6. Docker must be available
  7. Only reachable from within my home network
  8. Disk encryption
  9. Caching

Use cases
#

  • 75% (shared) file storage
  • 15% home lab running some Docker containers and VMs
  • 10% automation tasks
  • No media streaming or gaming server

The next decision to think about was to make or to buy. Of course, at first I looked at the current lineup of Synology and QNAP systems. Some models are promising, but in my opinion they do lack power for my home lab use case in terms of CPU or RAM. Additionally, I want to have a hacker friendlier system and not a “proprietary” OS. Furthermore, building my own system is cheaper (at least that’s what I thought đŸ¤Ŗ).

In the next chapter I will give you an overview of my shopping list for the new system.

Hardware
#

I am not a hardware guy and my last DIY build was in my youth 😆

My hardware is based on this article (GER). I must admit that I was a little overwhelmed thinking about my hardware choices, so I was very happy to find this article.

All components are working and the build itself was not too difficult. The case is quite big and offers plenty of space for these components as well as for your (thick) fingers 😉

Be aware that this is not an ECC RAM build!
Finished build - Lenovo X1 Carbon for scale
A closer look

Software
#

The next decision to think about was which operating system to run. From the beginning it was obvious to me that I can not run a plain Linux distribution. I will need a special OS for this purpose.

In the area of NAS operating systems a major player is TrueNAS CORE which is formerly known as FreeNAS. TrueNAS is an enterprise level storage solution and is build upon FreeBSD and the ZFS file system.

While researching about TrueNAS I stumbled over Unraid which claims to be a solution for all data users for any combination of hardware. Unraid is based upon Slackware Linux and XFS (though a community ZFS plugin is available).

Of course, there are other alternatives like openmediavault, EasyNAS, Rockstar, Proxmox, and more. Some of them are specialized for certain purposes like Media streaming and some of them just looked not very appealing or widely used for me.

In the following section I want to list the key features of Unraid and TrueNAS.

Unraid
#

  • Unraid is based upon Slackware Linux distribution, and I am quite familiar with Linux which makes me feel more comfortable and more confident.
  • Unraid offers a great flexibility regarding your hardware especially your drives. You can mix disks with arbitrary sizes and easily increase your storage by adding just a single drive to it. The only limitation is that the parity drive(s) must be equal or greater than your storage disks.
  • As mentioned, the default file systems are XFS for storage disks and btrfs for the cache disks. I have some experience with both file systems and in my opinion they are easier to handle.
  • Unraid requires a paid license based upon the number of drives you want to use. There is a 30 days trail with all features available.

TrueNAS
#

  • TrueNAS is based upon FreeBSD. Though, (Free)BSD is a Unix based system, at the time writing this post I don’t feel very comfortable and confident in using BSD based systems. Additionally, I have doubt that every software I might want to run is available. In the future this might change with TrueNAS SCALE but for now I don’t want to run beta software for my NAS.
  • ZFS is the file system of TrueNAS which I consider as superior file system with one drawback. I am not too familiar with it and a solution without learning a new complex file system would be preferable.
  • Being a RAID based NAS you have to think about your RAID setup and also consider drive swapping. I would prefer a system without the complexity of a RAID.
  • TrueNAS CORE is free and open source.

Both
#

  • Handle drive failure
  • Come with a web UI
  • Support drive encryption
  • Large adoption and community
  • Extensible and configurable

Considering all mentioned aspects I decided to install Unraid!

Unraid config and apps
#

Installation
#

Unraid boots only from a USB disk and runs completely from memory.

Your USB drive must contain a unique GUID (Globally Unique Identifier) and be a minimum 1GB in size and a maximum 32GB in size.

You should consider buying a stick from a well known brand.

Strangely, Unraid does not offer the official USB-creator for Linux.

Here are the steps to create an Unraid boot USB stick on Linux:

  • Download the release archive.
  • Format your USB drive for instance with gparted:
    • GPT table
    • New FAT32 partition
    • Mark it as bootable
    • Label the partition with UNRAID (Important!)
    • Copy the archive’s content to the USB stick
    • Run make_bootable_linux located on your disk (not the USB). The script should confirm that the stick is ready

You should not require a monitor or keyboard/mouse. If your BIOS is configured to automatically boot from USB, Unraid will start in the default non GUI mode and is available at its local IP. Try to open http://tower.local or look in your router network settings for the IP of your system.

Drive set up
#

The Asus Prime A320M-A mainboard has 6 SATA ports. My decision for the drive layout was as follows:

  • two parity drives which will cover two simultaneous drive failures.
  • two drives for the actual storage (the so called array) which are protected by the parity drives.
  • two SSD drives for caching. As the cache is not protected by the parity I decided to go with a pool of two SSDs so that the cache content is stored on two disks.

This layout will provide me my required fail-safe of two disks at the same time, a fast SSD cache and for my purpose enough space with the 2x4GB Array.

Drive layout in Unraid web UI
I should have bought bigger drives for the parity because if I want to increase the capacity I have to buy a drive for the parity as well as for the storage itself. This restriction originates from the fact that parity drives must always be equal or bigger then the biggest array drive and I can not just add another 4 GB drive because of no free SATA ports.

Shares
#

My data at the top level is structured in folders for personal data, business data, source code, media, etc. For each folder I created a share. Most of my shares are configured to use the cache with the yes:cache option. New files are primarily created on the cache (SSDs) if sufficient space is available. As the cache is not protected, a so-called mover component moves files from the cache to the array. My mover is set up to run every night. Only critical data is directly written to the array.

My shares are automatically mounted at access by systemd.

Plugins and Apps
#

This section gives an overview of my most important plugins and apps. Installation of the Community Apps Plugin is highly recommended.

Syncthing
#

I use Syncthing for many years as my synchronization software. Never had an issue with it. Folders are synchronized between my Laptop, NAS, and my root server. Syncthing is available as Docker app (via community apps).

Syncthing statistics

Restic
#

Syncthing is not a backup software! For backups, I use restic. Restic creates client side encrypted repositories on various storage providers (S3, SFTP, Wasabi, GCS, …). My provider of choice is backblaze. Restic is configured to keep several snapshots allowing me to restore data from a specific point in time. Restic’s installation is easy as it consists of a single binary. I wrote a script that runs a backup operation for each share.

Here is a snippet of my backup script. The first line runs the backup command for a share to a bucket. The second command checks that only 20 snapshots are kept.

/usr/local/bin/restic -r $BUCKET:foo backup /mnt/user/foo
/usr/local/bin/restic -r $BUCKET:foo forget --keep-last 20 --prune

User scripts
#

User scripts is a plugin that provides a front end to manage scripts that run periodically. Think of it as a cron management UI. My formerly mentioned restic script is triggered by this plugin. It also provides a log viewer via the web browser.

User-scripts web UI with default scripts

Krusader
#

Krusader is a file manager similar to Midnight and Total Commander. It is available as Docker app (via community apps) and I use it for browsing my files directly on the NAS.

Krusader file manager

Prometheus/Grafana
#

I use Prometheus and Grafana for monitoring my system. Both tools are very common across the industry ranging from large enterprises to small startups or private users. Prometheus is a time series database which stores metrics. Grafana is used to visualize those metrics via dashboards. Node-exporter is a plugin that provides the actual metrics to Prometheus.

Some metrics from Prometheus visualized in Grafana

Conclusion
#

I can’t say much about the hardware except it works, and my time spent on researching and buying was acceptable â˜ē. Unraid itself is really awesome. Of course, this can not be a comprehensive comparison because I’ve never got in touch with TrueNAS. Unraid offers simple storage and application management via a comfortable and snappy web UI. Unraid’s documentation is also well maintained and there are awesome community resources like Spaceinvader ONE’s and The Geed Freaks YouTube channels.


  1. The mainboard features 6 SATA ports and one NVMe connection. SATA 5 and 6 ports are not be available when a NVMe drive is connected! ↩︎