ZFS vs BTRFS vs mdadm?

I recently purchased a mini pc, specifically a HP 800 G4 Mini, to run some services, as an upgrade from my current N100 box.

I would like to have some storage redundancy in my setup, and my system will take 2 m.2 Nvme SSDs and a 2.5 sata ssd.

I plan to use the 2 Nvme SSDs in a mirror / raid1 array for applications and the 2.5 sata ssd for my OS.

I plan to use this storage for applications only, as I have a separate NAS.

Applications I would like to move to this box are mainly Pterodactyl panel for game servers, and LibreNMS, both of which use MySQL as their database. Services will run in docker.

My questions:

  1. Should I use ZFS mirror, BTRFS Raid 1 or mdadm with Ext4 on top? People keep telling me that running databases on CoW file systems are bad but I like the checksumming and snapshots that ZFS and BTRFS provide.

  2. How do I setup notifications in case a drive fails? I have a SNMP system setup via LibreNMS and would like notifications to preferably go through that.

  3. For my 2 Nvme drives in the raid array, should I get 2 different models from different manufacturers or is having 2 of the same drives fine?

2 Likes

I haven’t used BTRFS for a long time, but IIRC there were problems with multi-dev support / stability.
CoW vs DBs - this is more of a problem in case of HDDs - with COW, after a time, everything becomes “random read”.
In case of ZFS, be sure to read relevant perf guides (for both ZFS and MySQL settings) in order to void write amplification and free space fragmentation.

mdadm+ext4 should also be OK, as long as backups are up to date. This is the simplest setup.
I’d recommend it if you do not want to spend time learning ZFS.

I have no exp connecting anything custom to SNMP, so can’t help here.
However ZFS can log to system log and also has its own notification model (see: zed, zedlets)

I always try to get different manufactures, but try to get “comparable” models.

This will just add an extra blockdev, kernel, pagecache and FS to the mix.
Can be desirable if one intends to move this VM around independent of host, but for such a small system - I wouldn’t go this way.

It’s really a personal preference. I really like ZFS-on-Linux and the command line tools are sooo much better than btrfs. ZFS is so easy to work with once you get use to pools, snapshots, etc. I never got use to the way btrfs did subvolumes or snapshots and I’ve since abandoned it on everything after running it for years. (Yes, I even have a natively encrypted ZFS root + ZFSBootMenu).

I really want to see answers to this myself. I have little to no monitoring on my home infrastructure and I really need to get around to fixing that. I started setting up Telegraf + Grafana but haven’t made progress on it in a while. I have grafana-loki running for a lot of my side-project application logs.

It’s difficult to make sure you have the exact same number of blocks when you use different models. I would personally just buy identical drives.

1 Like

I running zfs on linux for the first time since 3 months and I can confirm this. I took me one afternoon to understand the basics and setup at debian install with zfs boot. The CLI tools are good and it was way less complicated than I expected. To me btrfs never felt production ready with the whole raid 5/6 troubles.

If you don’t need the system right away I would recommend to just try out your different options, it’s the best way to learn in my opinion.

Number of blocks does not matter. ZFS will just use smaller capacity as mirror vdev cap.
So if one has 2048 GB drive and 2049 GB and puts them in a mirror, then 2048 GB will be available for use.
When both will get replaced with bigger drives: more capacity will be available.

IMHO it is much important to limit the risk of faulty NAND, faulty controllers, firmware bugs etc.

Same :slight_smile:

I wouldn’t be too concerned trying to put DBs on ZFS, oracle literally use ZFS for this and SSD will mitigate this somewhat.

Either way, hardware sounds overkill for home DB use whatever filesystem you run.

ZFS will give you snapshots, fast rebuilds, data integrity checking, and can read different data from both sides of the mirror at the same time for improved speed (as it doesn’t need to compare both sides as checksums do the data integrity checking).

Traditional raid can’t do that.

1 Like

What might be noteworthy in the context of ZFS vs mdadm is, that while ZFS provides protection against bitrot (albeit it requires I think CoW and ECC memory to ensure your source is correct as well as the data on a target volume is), you (or I) usually need it only for data, that’s lying around a lot.

mdadm is usually faster though, especially on NVMe drives, than ZFS, but if it comes to rebuilding the array, it’s often slower than ZFS, because it rebuilds the entire array while ZFS resilvers only the data.

That said I also went with ZFS on my 4 U.2 NVMe SSDs.

1 Like

Also remember that raid (and zfs and btrfs) is not backup. Also confiture your mysql to backup and write transaction logs to an independent device. When the primary drive dies, and you restore your daily snapshot, you then need to roll back the database transaction log to current. And you should be able to get up to the transaction where the db died from your transaction log. Or if you had a bad transaction, like root dropping an auth table, you can remove that from the transaction log and still get all of the other transactions.

The problems are with parity raid (RAID5/6). Other modes are absolutely fine and production-ready (0/1/10/etc.). The btrfs tools will also give very scary warnings if you do something not recommended. BTRFS nowadays is well-tested and safe to use IMO.

For OP, given that he/she just wants a simple mirror, I’d recommend BTRFS. The big advantage of ZFS IMO is the availability of parity raid. if you only need a mirror BTRFS is the best option. The big drawback of ZFS is that it’s not in-tree and IMO should only be used on select distributions where you can be sure there’s out of the box support to avoid issues (especially if it’s for root).

mdadm mirrors have the big drawback vs. BTRFS or ZFS that you lose the self-healing properties. For a file system with ‘native’ raid support I’d always prefer that.

2 Likes

Boy did I learn this the hard way. I setup a ZFS mirror for my NVMe boot drives on Debian and that was insanely, wicked slow. Back on a normal, boring mdadm+ext4 and much happier. Still use ZFS for my HDDs, though.

1 Like

I just want to mention you need to set logbias=throughput to avoid double write on nvme ZFS pool.

Would this be true of SATA SSDs as well?

Unless you have a slog set up (eg mirrored Optane). Then you want logbias=latency

SATA will be the bottleneck. In this case, ZFS/BTRFS/MDADM doesn’t matter much.

In practice, you will also have compression + encryption. Max throughput is not that important.

I agree. Datasets in ZFS are way easier to work with and CLI is way more intuitive in that regard. Working with BTRFS over the years mitigated that on my side just by having practice and using it often. It’s way more intuitive than e.g. Ceph CLI is, or LVM and mdadm which should be easier because simpler.

One stop shop btrfs command is not bad once you figured out the method and design and structure of the “submenues” :wink:

I have BTRFS in use on several FS. But if I have the choice of just-works FS and I’m presented with ZFS, I run ZFS.

It always is. But the nature of bottlenecks is…there is always the next bottleneck waiting after you eliminate the present one. And after you fixed storage hardware and networking, memory bandwidth, kernel and generally software ,built for ages past, quickly take their place.
In the end it’s about being happy with the stuff you do and not waiting for storage more than necessary.

Use the stuff you’re familiar with and probably will stay with you for the next 10 years. Important to me is how it feels and whether it provides the utility that makes my stuff more easy and care-free to run. Storage just needs to work and not slow things down.

1 Like

I tend to prefer ZFS. Its protection against silent corruption is second to none, and its snapshots and command line management interface are amazing. Backups are also really convenient using the zfs send/recv function and sending stuff to another ZFS box. But it is not the right application for everything.

ZFS likes lots of RAM to perform well, and it is generally a good idea to use ECC for it. It also does use some CPU (though this is less of a big deal today with our modern CPU’s than it was years ago)

You would also not want to use ZFS for swap space, as it can create a race condition if you do. (RAM gets low, → greater need for swap space → ZFS ARC in RAM grows to accommodate more use → RAM is even lower → greater need for swap space → etc.)

BTRFS is much like ZFS, but I honestly don’t have much personal experience with it. I keep reading up on it to see where it stands, and keep hearing of people having problems.

MDADM is an OK traditional software RAID solution. CLI management is so-so, and can be a little counter-intuitive. I have a two way MDADM mirror on my all in one NAS/VM server that only does swap (because of the ZFS issue mentioned above) but honestly it sits empty most of the time.

ZFS can be hit or miss in the performance department. It tends to perform really well on hard drives and SATA SSD’s. Essentially any drive that is slow enough to allow for CPU operations while waiting for the drive will perform amazing on ZFS. This is especially true for traditional hard drives, where its copy on write block based design helps overcome the seek limited random reads of drives, by essentially converting everything into sequential reads. It was created in an era where traditional spinning hard drives were the norm, so the code kind of expects it to have ample time to do CPU computation while it waits for the drive.

This means that when NVMe drives are used as data drives, ZFS does not perform as well as expected. While it will still be faster than on hard drives or SATA SSD’s, oftentimes, even on slower Gen3 NVMe drives, if these drives are used in the main data pool, you can get performance below what you’d expect from a standalone drive.

ZFS can - however - utilize NVMe drives as caches and so called “special” vdevs (for metadata and small file storage) very well. These appear to be implemented in a way that is aware of modern high speed storage, and thus don’t appear to be held back as much by the problem where the CPU expects to be able to take its time while waiting for the drive.

Writes can also be sped up a lot by using special purpose low latency devices as SLOG/LOG/ZIL devices.

But this tends to mean that ZFS is best when used in larger more complex pools, that have large amounts of RAM, mass storage over SATA or SAS, some dedicated special devices that are NVMe for metadata and small files, some low latency devices (like Optane or battery backed RAM devices) for SLOG/LOG/ZIL and maybe even some read cache devices (which could also be NVMe) to speed up reads of frequently accessed files, while offloading the main data pool to do other stuff.

That said, you don’t have to have a large and complex ZFS pool to make use of ZFS. I have plenty of systems that boot off of simple two-way mirrors. Just don’t expect it to be a high performance solution with two NVMe drives. Many people have the expectation that a basic two-way mirror is going to have twice the read speeds of a standalone drive, and with NVMe in ZFS this will simply not be the case. Write speeds will also be comparatively slow (at least if they contain sync writes, which they likely should if you are using any kind of database)

So why do I still use ZFS this way? Easy. In those applications, performance is not the priority, and I love the reliability, flexibility and management of my ZFS pools.

What would I use instead if performance were a priority? Not sure. MDADM is not a performance screamer either. I simply don’t know enough about how BTRFS performs in this situation but from what I read there are enough issues that I am not ready to use it. At least not yet.

ZFS decked out to the nines with special devices, gobs of RAM, SLOG devices and cache devices can have great performance for things like databases and the like, but in a basic two-way mirror form, you will not be impressed by the performance. It won’t be terrible. It is totally usable, but it also won’t impress.

I think in applications where high performance is crucial out of a simple two drive pool, I’d probably just use standalone drives to be honest, and just have something set up to do regular backups.

The thing is, RAID is not backup. It helps you keep a greater uptime if something goes wrong, but it is never intended to replace the need for backups. You should be backing up either way.

Which brings me back to the advantage of ZFS send/recv.

If your other NAS you mention runs on ZFS it would be stupidly easy to set up backups from any ZFS based pool anywhere on the network to just send incremental block-for-block backups to the main NAS.

Anyway, I hope this helps.

5 Likes

RAID1 gets you enhanced read speed, which often doesn’t matter given how high fast reading is on a decent NVMe.

The typical reason to use RAID1 is to have no downtime in the case of one drive failure, that is - you get better availability.

However if your OS still sits on a single drive then you won’t get that benefit - with one drive failure you will be offline while you reinstall and reconfigure the OS could take a few minutes, or a few hours.

zfs, btrfs, mdadm will all work fine.

At home I tend not to bother thinking about mirroring, and focus on backups instead. As a general rule, human error remains a greater cause of outages than hardware faults, and has been the most common cause of loss data for me.

If you do go with mirroring I’d suggest mirroring your OS filesystems too. Beware of how the UEFI interacts with software mirroring and your ESP partition.

1 Like

Avoiding bad batches can be an topic, either buy from two different retailers and hope the disks are from different batches, or use two NVMe drives from different manufacturers that are as similar as possible and create partitions of the same size.
This isn’t a problem under Linux.

Whole disks vs partitions

ZFS will behave differently on different platforms when given a whole disk.

ZFS will also attempt minor tweaks on various platforms when whole disks are provided. On Illumos, ZFS will enable the disk cache for performance. It will not do this when given partitions to protect other filesystems sharing the disks that might not be tolerant of the disk cache, such as UFS. On Linux, the IO elevator will be set to noop to reduce CPU overhead. ZFS has its own internal IO elevator, which renders the Linux elevator redundant. The Performance Tuning page explains this behavior in more detail.

https://openzfs.readthedocs.io/en/latest/performance-tuning.html

very well put and this has me more interested in truenas experimentation

1 Like

I got a Kingston KC3000 and a Crucial T500 and put them in a BTRFS mirror in the end.