TrueNAS - Home Server
This post assumes some rudimentary knowledge about computer hardware, servers, and TrueNAS!
I had a Dell PowerEdge T330 lying around, and I wanted to build something! I had also been thinking about building a backup server for my family's huge collection of family videos on DVD and even VCR tapes.
There is a common phrase for the ideal backup strategy called '3-2-1':
With more redundancy, the less likely it will be that you lose your most important data, such as thousands of photos of friends and family, or important documents.
With a server lying around, it made perfect sense to create a backup server for our family's humongous library of home DVDs and tapes.
Nothing amazing, but good enough for a backup server:
Let's go over some requirements for the server.
TrueNAS is an open-source operating system used to manage network-attached storage (NAS) servers. It is based on FreeBSD and the OpenZFS filesystem.
To answer this, we have to understand how OpenZFS, the file system for TrueNAS, works. ZFS has features such as pooled storage and snapshots. ZFS can also configure software RAID configurations, such as RAID-Z (akin to RAID5). There have been many TrueNAS community posts advising against using hardware RAID controllers with ZFS, since this could obfuscate the status of hard drives to ZFS software. The PowerEdge T330 I have is configured with a PERC H730 Hardware RAID Controller attached to an 8-drive hot-swap SATA/SAS Backplane. There's our problem: how will I take advantage of this backplane if TrueNAS doesn't play nice with Hardware RAID Controllers?
If I want to take advantage of all the drive bays, I need to use the backplane and therefore the PERC H730. Without the backplane, I can only attach 2 SATA drives to the motherboard alone. This would not support my requirement to have 1 boot drive and 2 mirrored drives.
If I'm going to keep cost low, I do not want to have to purchase a new RAID card. To increase compliancy with ZFS, it is advised to use drives connected in HBA (host bus adapter) mode. The PERC H730 is capable of HBA mode. Some TrueNAS forum posts suggest buying a PERC H330 controller (around $100 used) and "cross-flashing" it to "IT-mode" to enable a true HBA mode. With a cursory glance, the H330 and H730 seem to be built from the same DNA, so the H730 should be fine. The next section addresses how to enable HBA mode on the H730.
Some TrueNAS forum posts suggests against using the H730, but my testing found it to be sufficiently stable.
Here are some additional posts to read, if you're interested:
There are two ways to enable HBA mode: 1) "IT-Mode", where you can cross-flash your H730 to IT-mode using LSI firmware, or 2) "BIOS HBA Mode", where you can enable HBA mode using the Device Settings in the BIOS. I decided to avoid cross-flashing as this TrueNAS post suggests that I would have to remove the H730's battery. Instead, I went with option 2), and enabled HBA mode using the BIOS. This took a few attempts since I got a warning message the first couple times.
This guide worked:
# 1. Boot into BIOS using the F2 key
# 2. Navigate to Device Settings > Integrated RAID Controller
# 3. Clear config
Configuration Management -> Clear Config -> Confirm -> Yes
# 4. Clear events
Controller Management -> Advanced Controller Management -> Clear Controller Events -> OK
# 5. Reset to defaults
Controller Management -> Advanced Controller Management -> Clear Controller Events -> Set Factory Default -> Set Factory Defaults -> confirm -> OK
# 6. Switch to HBA mode
Controller Management -> Advanced Controller Management -> Switch to HBA Mode you should be then ready to go.Below is a summary of the aforementioned alternatives in addressing the Hardware RAID Issue with TrueNAS:
Rank | Alternative | Pros | Cons |
1 | H730 in BIOS HBA mode | No issues with ZFS, if tested properly | Requires stability tests |
2 | H730 Cross-flashed | ZFS may prefer this over BIOS HBA mode | Cross-flashing is risky. Can restore original H730 firmware using the tool, but the battery needs to be removed! |
3 | H310 Non-RAID SAS2 controller Cross-flashed | No issues with ZFS | Out of budget. $100 CAD |
4 | SATA-connected drives to Motherboard | No issues with ZFS | Can't use 8 drive bays. Must use internal drive bays. Only 2 supported SATA ports on motherboard. |
5 | H730 in RAID Mode | No changes to system | ZFS and hardware RAID could be bad - hardware RAID obfuscates the "true" status of physical drives from ZFS in TrueNAS. In the event of a failure, as in the H730 controller dies, it could be harder to recover the data than if the config were software raid. |
Although it is possible that the H730 could still be writing to the drives in a proprietary format as determined by Dell, I accept the risk because:
In the next section, I outline failure testing for the BIOS HBA mode, which suggested to me that the PERC H730 does not write to the disks in a proprietary format in HBA mode. (If I wanted to be 100% certain, I could connect the drives via a SATA to USB bridge to a different computer with ZFS support.)
There are some posts suggesting that in the event of a drive failure, data recovery may be difficult using a RAID controller:
I ran a test to recover data in the event that the RAID controller dies but the rest of the T330 server is still working.
First I installed TrueNAS on the server. Skip to the next section to see the process I took for the final install.
Here is the TrueNAS configuration I used for testing:
I connected to the SMB share and copied over about 70GB of photos to the drives. Since the drives are in a mirror configuration, the files are exist on both drives.
Next, I wanted to try removing one of the drives to access it on my Mac with a SATA to USB bridge. I connected one of the Mirrored 70GB drives from the T330 to my computer. Unfortunately, the setup (installer and homebrew cask) did not work, and after turning on the required kernel extensions in macOS, I decided to pivot. I instead installed Ubuntu Server on a spare drive in the T330, and installed openzfs there instead, see below:
The following code block is from https://svennd.be/mount-unknown-filesystem-type-zfs_member/.
# After installing Ubuntu server from usb drive:
# Boot into Unbuntu Server
# install openzfs
sudo apt install zfsutils-linux
# check zpool
sudo zpool import
# mount disk with zpool
sudo zpool import "your pool name" -f
# find mountpoint
zfs get all "your pool name" | grep mountpoint
# mount
zfs mount "your pool name"The following tests showed that I was able to access the pool I created on TrueNAS from a different OS, with and without the H730. I tested 3 scenarios: Scenario 1 assumes that no drives have failed in the mirror; scenarios 2 and 3 assume that 1 drive in the mirror has failed; and scenario 3 assumes that the H730 controller has failed.
Scenarios:
All scenarios yielded accessible original data. I was satisfied with this result, and moved on to a final install of TrueNAS.
The following section outlines the OS I chose (TrueNAS Core vs TrueNAS Scale), the hardware configuration, and the software I chose to run on the server to satisfy the project requirements.
A little experimenting with TrueNAS Core revealed that the plugin support was lacking. I could not get Jellyfin (video streaming) working. I decided to try TrueNAS Scale's apps, which felt more polished compared to TrueNAS Core's plugins.
To prevent data loss in the event of an unexpected power failure, I am using a battery backup or UPS (Uninterruptible Power Supply). Upon power failure, such as when a storm knocks down power lines, the UPS will keep the server powered and it will send a signal to TrueNAS to shut down the server safely. TrueNAS uses NUT to interface with the UPS.
To setup my battery backup, I connected it to the T330 via USB. Next, from the truenas.local web interface, I navigated to System Settings>Shell. I entered the commands below, as referenced from this guide:
# 1. List UPS connected
sudo nut-scanner -U
# Output:
Scanning USB bus.
[nutdev1]
driver = "usbhid-ups"
port = "auto"
vendorid = "0764"
productid = "0501"
product = "BRG1500AVRLCD"
serial = "xxxxxxx"
vendor = "CPS"
bus = "001"
# 2. Configure UPS Service: System Settings>Services>UPS>Configure
# Used defaults but added the following:
Driver: Cyber Power Systems ups 3 CP1500EPFCLCD USB (usbhid-ups)
Shutdown Command: /sbin/shutdown -h
Power Off UPS: True
# Left everything else as in this guide mentioned earlier.
# 3. Start UPS Service: System Settings>Services>UPS>Toggle to "Running"
# 4. Test the connection to the UPS
upsc ups@localhostNow I can rest easy when initiating large transfers!
Upon setting up a Time machine share, I had to set the "Purpose" to "Basic time machine share" instead of Multi-user time machine share. Multiple macs should be able to backup with the basic share. You can tweak the ACL to only allow certain users to backup to it.
I tested file transfer speeds by transferring 150GB of photos to the server. Speeds topped out and sustained around 45MB/s or 360Mbps on our network. Transferring a 21GB zip file sustained 120MB/s, which is line speed for 1Gb networking. With Jellyfin, I could stream videos on 2 concurrent devices with no issues.
This project took about a week to complete and I learned an incredible amount along the way. It was super fun! Below are some of my lessons learned and next steps.
Thanks for reading through this long post! I hope you learned something about servers, RAID controllers, TrueNAS, or maybe just what a NAS is!