Author Topic: RAID, btrfs vs MDraid  (Read 10130 times)

0 Members and 1 Guest are viewing this topic.

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5133
  • Country: gb
RAID, btrfs vs MDraid
« on: August 04, 2026, 09:37:36 am »
The new ZimaOS running on ZimaBoard2 has a strange choice.

They use MDraid instead of btrfs  :o :o :o :o :o

What I don't understand is that btrfs automatically detects and fixes bitrotting, while MDraid doesn't.

So why?

Seriously, their ZimaOS is based on Linux and it already has btrfs compiled and installed with all the tools, so why not use it for every RAID?

In my case, my NAS is based on four PowerPC 4xx SoC @ 133MHz nodes with 128MB of SDRAM each.
I have both low CPU power and low RAM, so I don't use btrfs because I don't have the resources to run it.

I built a bare-bones minimal Linux kernel, and the rootFS is based on MUSL. MDraid runs more than decently, aided by some programs I wrote in userspace to continuously monitor disk health (via S.M.A.R.T.) and continuously check the hash of the most important files. Essentially, I wrote an application that cyclically calculates the MD5 of the files to be monitored (90% read-only archives, pdf, c-sources, txt, tgz, ..., but I can modify them and update the MD5 on the trusted node), then queries a trusted node over the network to see if the checksum is correct.

If it's incorrect, it means there's been silent corruption, and MDraid has NOT detected it, so potentially I could have a healthy copy on disk1, which is silently getting corrupted by the corrupt copy on disk2, because they are both mirrored.

So far, in 10 years, this has only happened twice, I think it has a very low probability of happening, but with SSDs&C... FLASH-based... who knows? I only have experience with HDDs., anyway, in both cases, a corrupted bit on the mirror also corrupted the copy on the second HDD!

This is where a DVD-RAM backup literally saves your day, because if that corrupt bit is in the right place, you might not be able to unpack a compressed archive and lose some stuff.

-

But! But the Zima can have up to 16GB of RAM, and its CPU is an Intel N150 class, which is decidedly powerful.
They have all the resources to use btrfs for raid1 (mirroring), yet they rely on MDraid...

I think I didn't understand  their point :-//

The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline BradC

  • Super Contributor
  • ***
  • Posts: 2526
  • Country: au
Re: RAID, btrfs vs MDraid
« Reply #1 on: August 04, 2026, 10:05:31 am »
The new ZimaOS running on ZimaBoard2 has a strange choice.

They use MDraid instead of btrfs  :o :o :o :o :o

What I don't understand is that btrfs automatically detects and fixes bitrotting, while MDraid doesn't.

So why?

mdraid is tested, reliable and deterministic. It's also fairly easy to recover when you do something silly. btrfs is passable for mirroring, but having attempted to help several mates who'd lost multiple TB to btrfs I wouldn't touch it with your 10 foot pole.
 
The following users thanked this post: DiTBho

Offline Whales

  • Super Contributor
  • ***
  • Posts: 2712
  • Country: au
    • Halestrom
Re: RAID, btrfs vs MDraid
« Reply #2 on: August 04, 2026, 10:15:34 am »
I have had bad experiences (data loss, bugs) with btrfs.  Additionally several of its RAID modes are completely broken, unsafe or incomplete.

mdraid is reliable and doesn't lock you into one filesystem.
 
The following users thanked this post: DiTBho

Offline Whales

  • Super Contributor
  • ***
  • Posts: 2712
  • Country: au
    • Halestrom
Re: RAID, btrfs vs MDraid
« Reply #3 on: August 04, 2026, 10:18:55 am »
If you want filesystems with file-level checksums then I might suggest bcachefs (newer, but I have been stably running without data loss for 2 years, for the 2c that's worth) or ZFS (more traditional, better tested).  EDIT: but this will all be less performant than mdraid + ext4, because of the extra work & features.
« Last Edit: August 04, 2026, 10:21:09 am by Whales »
 
The following users thanked this post: DiTBho

Offline Whales

  • Super Contributor
  • ***
  • Posts: 2712
  • Country: au
    • Halestrom
Re: RAID, btrfs vs MDraid
« Reply #4 on: August 04, 2026, 10:30:23 am »
Triple posting sorry :D

[...]then queries a trusted node over the network to see if the checksum is correct.

[...]

So far, in 10 years, this has only happened twice, I think it has a very low probability of happening, but with SSDs&C... FLASH-based... who knows? I only have experience with HDDs., anyway, in both cases, a corrupted bit on the mirror also corrupted the copy on the second HDD!

You've observed and noted the problem on both disks, but how are you so certain the cause was something a better filesystem or RAID could even fix?

Bits undesirably flip in DRAM, buses and SRAM occasionally.  If you have ever read ECC correction counters in ECC equipped computers you will have observed this.  This process launders data corruption into being legitimate (both disks will end up with identical, agreeing copies).  Filesystems sometime shuffle blocks and data around as optimisations, so you don't even need to choose to write to a file for this to potentially happen.

Regarding SSDs vs HDDs: it depends on who made them.  They're usually competitive in terms of reliability, but I've had some really bad cheap NVME before whilst it seems all the dodgier HDD companies died out decades ago.  Stick to the major brands.
« Last Edit: August 04, 2026, 10:31:56 am by Whales »
 
The following users thanked this post: DiTBho

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4665
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: RAID, btrfs vs MDraid
« Reply #5 on: August 04, 2026, 10:31:31 am »
As far as I know you can still do an md-raid and then run a btrfs filesystem on it. Perhaps slightly less efficient, but okay.
The alternative more mature ZFS can also be used.

However considering none of this hardware is enterprise grade ecc covered, using mdraid is a sane simple choice.
 
The following users thanked this post: DiTBho

Offline madires

  • Super Contributor
  • ***
  • Posts: 9312
  • Country: de
  • A qualified hobbyist ;)
Re: RAID, btrfs vs MDraid
« Reply #6 on: August 04, 2026, 10:57:05 am »
btrfs: file system and logical volume management including some RAID features
mdraid: software RAID framework

mdraid is the gold standard of linux software RAIDs and, as already mentioned, pretty reliable. I agree with Whales that mdraid + ext4 should be the best option for low-performance SoCs.
 
The following users thanked this post: DiTBho

Online gf

  • Super Contributor
  • ***
  • Posts: 1851
  • Country: de
Re: RAID, btrfs vs MDraid
« Reply #7 on: August 04, 2026, 10:57:16 am »
The new ZimaOS running on ZimaBoard2 has a strange choice.

They use MDraid instead of btrfs  :o :o :o :o :o

What I don't understand is that btrfs automatically detects and fixes bitrotting, while MDraid doesn't.

So why?

While mdraid stores data redundantly, it does not generate its own checksums. Instead, it relies entirely on the built-in checksum and ECC capabilities of the drive, transmission bus, and system memory.

Conversely, Btrfs stores filesystem-level checksums within its metadata, allowing it to validate every read operation. If the data is stored on a native Btrfs RAID array, the filesystem can automatically locate and recover a healthy copy with a matching checksum.
 

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5133
  • Country: gb
Re: RAID, btrfs vs MDraid
« Reply #8 on: August 04, 2026, 11:32:36 am »
Triple posting sorry :D

[...]then queries a trusted node over the network to see if the checksum is correct.

[...]

So far, in 10 years, this has only happened twice, I think it has a very low probability of happening, but with SSDs&C... FLASH-based... who knows? I only have experience with HDDs., anyway, in both cases, a corrupted bit on the mirror also corrupted the copy on the second HDD!

You've observed and noted the problem on both disks, but how are you so certain the cause was something a better filesystem or RAID could even fix?

Bits undesirably flip in DRAM, buses and SRAM occasionally.  If you have ever read ECC correction counters in ECC equipped computers you will have observed this.  This process launders data corruption into being legitimate (both disks will end up with identical, agreeing copies).  Filesystems sometime shuffle blocks and data around as optimisations, so you don't even need to choose to write to a file for this to potentially happen.

The "trusted node" receives a copy of the file over the network for the sole purpose of calculating the MD5, which it then writes to its database. It's supposed to be "a trusted node" because it has an ECC controller, while the other NAS nodes have a simple SDRAM controller without parity checking.

What I saw was that disk 1 had a correct copy, disk 0 corrupted a bit, and the RAID mirroring silently corrupted the file on disk 1 as well.

Code: [Select]
RAID-mirror
main | copy
hdd0 | hdd1
-----|-----
Good | Good
bad! | Good   <------- it didn't detect any corruption, I know what happened from the reconstruction of the logs
bad! | bad!   <------- the file on HDD1 was correct, but the RAID mirroring silently forced to update with the corrupted version from HDD0

The problem is that the application I wrote to perform the cyclic check is very slow at checking all the files without impacting performance; that is, if it detects a file being copied, it pauses itself. In fact, using the NAS all the day, the checks are performed at night, or very early in the morning, when all file IO activity is zero. In any case, it has a huge b+tree-based database ( file_string(path,name) -> 32bit-checksum) that it updates every time I modify a file, which it then uses to recheck a file's checksum from time to time. In this way, corruption becomes apparent, albeit very late.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
The following users thanked this post: Whales

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5133
  • Country: gb
Re: RAID, btrfs vs MDraid
« Reply #9 on: August 04, 2026, 11:35:34 am »
The new ZimaOS running on ZimaBoard2 has a strange choice.

They use MDraid instead of btrfs  :o :o :o :o :o

What I don't understand is that btrfs automatically detects and fixes bitrotting, while MDraid doesn't.

So why?

While mdraid stores data redundantly, it does not generate its own checksums. Instead, it relies entirely on the built-in checksum and ECC capabilities of the drive, transmission bus, and system memory.

Conversely, Btrfs stores filesystem-level checksums within its metadata, allowing it to validate every read operation. If the data is stored on a native Btrfs RAID array, the filesystem can automatically locate and recover a healthy copy with a matching checksum.

Precisely! But ZimaOS uses MD-raid instead of Btrfs-raid!
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Online gf

  • Super Contributor
  • ***
  • Posts: 1851
  • Country: de
Re: RAID, btrfs vs MDraid
« Reply #10 on: August 04, 2026, 11:43:47 am »
Precisely! But ZimaOS uses MD-raid instead of Btrfs-raid!

When Btrfs runs on top of a non-native, foreign RAID, it can still detect checksum errors but I think it cannot auto-repair them, as it lacks control over the redundant data copies.
 
The following users thanked this post: DiTBho

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4665
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: RAID, btrfs vs MDraid
« Reply #11 on: August 04, 2026, 12:50:11 pm »
md-raid does not guarantee any of those features, so there will never be a false sense of security.

zfs/btfs may still write a corrupted block due to a memory fault to all disks.
 
The following users thanked this post: DiTBho

Offline exe

  • Supporter
  • ****
  • Posts: 3130
  • Country: nl
  • self-educated hobbyist
Re: RAID, btrfs vs MDraid
« Reply #12 on: August 04, 2026, 02:50:52 pm »
I had bad experiences with both btrfs (long time ago), and zfs (1 year ago on ubuntu).

Particularly with zfs, I had huge problems when using docker (freezes, kernel panics), and when trying to update the kernel -- zfs was often not ported yet to the most recent kernel, etc. Ah, and speed... it was horrible. Even if it was faster than ext4, the amount of maintenance it required wouldn't worth it for me. Oh, and it needs quite some RAM to work. Going back to ext4 was a big relief, the system was so much faster... Ah, docker was configured to use ZFS natively, without it (default setting on ubuntu it was) the performance was so miserable... like 10x slower, I did benchmarks. Idk why would anyone use it, particularly on server, or for a database.

Btrfs -- idk, may be it's okay now. But the fact that RHEL removed it doesn't instill confidence. 10 years ago it was semi-stable. I had lock-ups during intense IO while, say, doing snapshots, making it unusable for me.

At the end, I'm now on back to lvm+ext4+encryption. All that CoW ideas and flexible volume management sound good in theory, but I gave up on that. I almost never need to resize or grow my volumes, but I had to pay for those feature every moment I was using my computer.

Having said that, I don't mind if there is something as reliable, performant and convenient as ext4, but with more features. It's just making a new fs is quite some investment, and market is quite niche, but who knows... Also, for me IT equipment is quite disposable nowadays. I'd rather rely on backups, health checks and fast recovery, than fancy fs that can repair itself. I do want error detection.
 

Online DiTBhoTopic starter

  • Super Contributor
  • ***
  • Posts: 5133
  • Country: gb
Re: RAID, btrfs vs MDraid
« Reply #13 on: August 04, 2026, 04:11:35 pm »
mdraid + ext4 should be the best option for low-performance SoCs.

That's exactly my configuration  ;D
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline BradC

  • Super Contributor
  • ***
  • Posts: 2526
  • Country: au
Re: RAID, btrfs vs MDraid
« Reply #14 on: August 04, 2026, 11:43:09 pm »
mdraid + ext4 should be the best option for low-performance SoCs.

I don't know if they qualify as "low-performance" but I've spent years optimising systems driven by RPi's. Don't discount xfs either. On spinning rust, ext4 is great for "normal" filesystems. Filesystems with lots of metadata (say for example hardlinked rsync incremental backups) I've found xfs a better performer.
If the drive/array is SSD then either is good, it just seems xfs is better at consolidating metadata for access on storage that penalises seeks.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->