Like many other MacBook Pro users, I encountered the issue of insufficient internal storage. To be more precise, my daily-use rMBP was equipped with only a 256GB SSD, which, as you can imagine, didn’t last long.
And when I started recording videos during my flights, the situation only worsened. The amount of footage from such flights exceeded 50+ GB, and my unfortunate 256GB SSD filled up quickly, forcing me to purchase an external 1TB drive. Yet, after just one year, it also struggled to handle the volume of data I was generating, not to mention that the lack of redundancy and backups made it unsuitable for storing important information.
So, at one point, I decided to build a large-volume NAS, hoping that this system would last at least a couple of years without requiring another upgrade.
I wrote this article primarily as a reminder of what I did and how I did it in case I need to do it again. I hope it will be useful for you as well if you decide to do the same.
Maybe it’s simpler to just buy one?
So, we know what we want to achieve; the remaining question is how?
At first, I looked at commercial solutions and specifically considered Synology, which is thought to offer the best consumer-level NAS systems on the market. However, the cost of this service turned out to be quite high. The cheapest system with 4 bays costs $300+, and hard drives are not included. Moreover, the internal components of such a setup are not particularly impressive, which raises questions about its real performance.
That’s when I thought: why not build a NAS server myself?
Searching for the right server
If you plan to assemble such a server, the first thing you need is to find the right hardware. A second-hand server should work well for this build, as we won’t require high performance for storage tasks. The essentials include a large amount of RAM, several SATA connectors, and good network cards. Since my server will operate in my permanent residence, noise levels also matter.
I began my search on eBay. Although I found many used Dell PowerEdge R410/R210 units priced under $100, with my experience in server rooms, I knew that these 1U units are too noisy and not suitable for home use. Generally, tower-form servers tend to be quieter, but unfortunately, there were very few available on eBay, and all of them were either expensive or underpowered.
The next place I looked was Craigslist, where I found someone selling a used HP ProLiant N40L for just $75! I was familiar with these servers, which usually sell for around $300 even in used condition, so I sent a message to the seller hoping the listing was still active. Upon learning that it was, I quickly headed to San Mateo to pick up this server, which I was immediately pleased with at first glance. It showed minimal wear, and apart from a bit of dust, everything else was excellent.

Photo of the server right after purchase
Here are the specifications of the set I acquired:
- CPU: AMD Turion(tm) II Neo N40L Dual-Core Processor (64-bit)
- RAM: 8 GB non-ECC RAM (installed by the previous owner)
- Flash: 4 GB USB Drive
- SATA Connectors: 4 + 1
- NIC: 1 Gbps on-board NIC
Needless to say, despite its several years of age, the specifications of this server still surpass most NAS system options available on the market, especially regarding RAM. A bit later, I even upgraded to 16 GB ECC with an increased buffer size and enhanced data protection.
Choosing Hard Drives
Now that we have a great working system, it's time to select hard drives for it. Obviously, for that $75, I only received the server itself without HDDs, which did not surprise me.
After some research, I found that for 24/7 NAS systems, WD Red HDDs are the best choice. I ordered 4 of 3 TB each from Amazon. Essentially, you can connect any preferred HDD, but make sure they are of the same capacity and speed. This will help you avoid potential performance issues with RAID in the future.
System Setup
I think many will use the , and there is nothing wrong with that. However, despite the possibility of installing this system on my server, I preferred to use CentOS, as the ZFS on Linux system is initially prepared for a production environment, and I am generally more familiar with Linux server management. Additionally, I wasn't interested in the trendy interface and features offered by FreeNAS – a RAIDZ array and AFP sharing were sufficient for me.
Installing CentOS on a USB is quite simple – just specify the USB as the boot source, and the installation wizard will guide you through all its stages upon startup.
RAID setup
After successfully installing CentOS, I also installed ZFS on Linux, following the steps listed .
At the end of this process, I loaded the ZFS Kernel module:
$ sudo modprobe zfs And I created a RAIDZ1 array using the command zpool:
$ sudo zpool create data raidz1 ata-WDC_WD30EFRX-68AX9N0_WD-WMC1T0609145 ata-WDC_WD30EFRX-68AX9N0_WD-WMC1T0609146 ata-WDC_WD30EFRX-68AX9N0_WD-WMC1T0609147 ata-WDC_WD30EFRX-68AX9N0_WD-WMC1T0609148
$ sudo zpool add data log ata-SanDisk_Ultra_II_240GB_174204A06001-part5
$ sudo zpool add data cache ata-SanDisk_Ultra_II_240GB_174204A06001-part6 Note that here I am using the hard drive IDs instead of their displayed names (sdx), to reduce the chance of mount failure after boot due to drive letter changes.
I also added a ZIL and L2ARC cache running on a separate SSD, partitioning this SSD into two parts: 5GB for ZIL and the remainder for L2ARC.
Regarding RAIDZ1, it can tolerate the failure of 1 disk. Many assert that this pool option should not be used due to the likelihood of a second disk failing during RAID reconstruction, which risks data loss. However, I disregarded this recommendation since I regularly made backups of important data on a remote device, and the failure of even the entire array may only affect data accessibility, not its preservation. If you cannot make backups, it would be better to use solutions like RAIDZ2 or RAID10.
To ensure the successful creation of the pool, you can execute:
$ sudo zpool statusand
$ sudo zfs list
NAME USED AVAIL REFER MOUNTPOINT
data 510G 7.16T 140K /mnt/data By default, ZFS mounts the newly created pool directly in /, which is generally undesirable. You can change this by executing:
zfs set mountpoint=/mnt/data dataFrom here, you can choose to create one or multiple datasets for data storage. I created two, one for Time Machine backup and the other for general file storage. I limited the Time Machine dataset to a quota of 512 GB to prevent its indefinite growth.
Optimization
zfs set compression=on dataThis command enables ZFS compression support. Compression uses minimal CPU power, but can significantly improve I/O throughput, so it is always recommended.
zfs set relatime=on data With this command, we reduce the number of updates to atime, to decrease IOPS generation when accessing files.
By default, ZFS on Linux uses 50% of physical memory for ARC. In my case, with a small total number of files, this can be safely increased to 90%, as no other applications will be running on the server.
$ cat /etc/modprobe.d/zfs.conf
options zfs zfs_arc_max=14378074112Then, using , you can verify that the changes have taken effect:
$ python arc_summary.py
...
ARC Size: 100.05% 11.55 GiB
Target Size: (Adaptive) 100.00% 11.54 GiB
Min Size (Hard Limit): 0.27% 32.00 MiB
Max Size (High Water): 369:1 11.54 GiB
...Setting up recurring tasks
I used to set up systemd timers for cleanup once a week and for automatically creating state snapshots every 15 minutes, 1 hour, and 1 day.
Installing Netatalk
is an open implementation of AFP (). Following S, I had a built and installed RPM package in just a couple of minutes.
Configuring
$ cat /etc/netatalk/afp.conf
[datong@Titan ~]$ cat /etc/netatalk/afp.conf
;
; Netatalk 3.x configuration file
;
[Global]
; Global server settings
mimic model = TimeCapsule6,106
; [Homes]
; basedir regex = /home
; [My AFP Volume]
; path = /path/to/volume
; [My Time Machine Volume]
; path = /path/to/backup
; time machine = yes
[Datong's Files]
path = /mnt/data/datong
valid users = datong
[Datong's Time Machine Backups]
path = /mnt/data/datong_time_machine_backups
time machine = yes
valid users = datong Note that vol dbnest is a significant improvement in my case, as by default Netatalk writes the CNID database to the root of the file system, which was quite undesirable since my main file system runs on USB, making it relatively slow. Enabling vol dbnest results in saving the database in the root of the Volume, which, in this case, refers to the ZFS pool and is significantly more efficient.
Enabling ports in the Firewall
$ sudo firewall-cmd --permanent --zone=public --add-service=mdns
$ sudo firewall-cmd --permanent --zone=public --add-port=afpovertcp/tcp sudo firewall-cmd --permanent --zone=public --add-port=afpovertcp/tcp
If everything was set up correctly, your machine should appear in Finder, and Time Machine should also work.
Additional settings
S.M.A.R.T monitoring
It is recommended to monitor the status of your drives to prevent failures.
$ sudo yum install smartmontools
$ sudo systemctl start smartdUPS daemon
Monitors the charge of the APC UPS and shuts down the system when the charge is critically low.
$ sudo yum install epel-release
$ sudo yum install apcupsd
$ sudo systemctl enable apcupsdHardware upgrade
A week after setting up the system, I began to worry more and more about the fact that the server had non-ECC memory installed. Moreover, with ZFS, additional memory for caching would be very helpful. So I went back to Amazon, where I purchased 2x Kingston DDR3 8GB ECC RAM for $80 each and replaced the desktop RAM installed by the previous owner. The system booted up on the first try without any issues, and I confirmed that ECC support was enabled:
$ dmesg | grep ECC
[ 10.492367] EDAC amd64: DRAM ECC enabled.Result
I was very pleased with the result. Now I can constantly load a 1Gbps LAN connection on the server by copying files, and Time Machine works flawlessly. Overall, I'm satisfied with the setup.
Total cost:
- 1 * HP ProLiant N40L = $75
- 2 * 8 GB ECC RAM = $174
- 4 * WD Red 3 TB HDD = $440
Total = $689
Now I can say that the price was worth it.
Do you build NAS servers yourself?
Source: habr.com
