r/Snapraid • • Jun 08 '26

Blue-sky question about using mergerfs to help with failed drive recovery for Snapraid

[See the resolution to my issue at the end of this description.]

This may be a weird question, but it has come up a lot lately that it is a very bad time to buy a replacement for a large HDD that has failed in a Snapraid array.

So my question: Would it be possible to throw together a quick MergerFS pool built from two smaller drives (which I might already have in my retired drive collection) to create a virtual drive large enough to substitute for the failed drive (during file recovery) in my Snapraid array?

The idea would be to use this only long enough to recover all of the contents of the failed drive into a sufficiently large virtual drive, after which the recovered files could be redistributed so that a smaller actual drive could be substituted back in. This drive would have been too small to directly replace the failed drive if the failed drive contained too much data to fit on this smaller drive. (And it is assumed that I simply can't obtain a drive large enough to directly replace the original failed drive).

What do we think, could this possibly work?

I know that in general, one should apply Snapraid protection directly to the physical drives underpinning a mergerfs filesystem, but this would be a special case. And no concern if the solution might be inefficient. The only goal is to accomplish a full file recovery while avoiding an unaffordable purchase quandary. Or to get my Snapraid array back into service more quickly if there would be a long lead time for purchasing a proper replacement drive.

(reposted from r/mergerfs for wider Snapraid community input. Already some useful comments there.)

[Edited by the OP to update with some resolution]

It turns out that MergerFS works well to address the problem as stated, provided I use only the Snapraid commands 'fix' and 'check' during the temporary MergerFS setup for file recovery. Remember that the use of MergerFS in this case is only for file recovery, so don't run 'sync' until after the Snapraid array has been put back to a new normal configuration with only physical drives. There are some definite advantages to the MergerFS approach to this problem, in comparison to the needs of LVM or mdadm, actually requiring fewer spare drives for the complete procedure. See details of all this in the comment from u/amadvance, and my reply elsewhere in this post

3 Upvotes

15 comments sorted by

3

u/lyothan Jun 08 '26

You probably can use a lvm to create a single large drive. I don’t know if mergerfs will work since snapraid read the drive uuid. It might work with mergerfs

1

u/BootToggle Jun 11 '26 edited Jun 11 '26

It turns out that mergerfs is sufficient for this problem, provided I use snapraid only for 'fix' and 'check'. There are also some advantages to this in comparision to the needs of LVM. See some details of this in the comment from u/amadvance, and my reply, elsewhere on this posting.

3

u/amadvance Jun 10 '26

I just tried it, and it works.

Mount the mergerfs directory, change the snapraid.conf "data DISK_NAME" path to point to that directory, and run:

snapraid fix -d DISK_NAME

Obviously, this makes sense only for 'fix' and 'check' during an emergency recovery. It is not recommended for normal operations, like 'sync' and 'scrub', because mergerfs will hide the underlying devices.

1

u/BootToggle Jun 10 '26 edited Jun 22 '26

That's perfect! Yes, 'fix' and 'check' only. Maybe 'diff' to see if anything is still un-recovered?

One advantage to using mergerfs here, vs. using LVM or mdadm, is that the larger of the two mergerfs drives is immediately ready to become the final substitute drive in the reconstituted Snapraid array. This is because it is already normally formatted, and after completing 'fix' the operation of mergerfs will cause it to already contain about half the recovered files.

With that, the only files that that must be redistributed are the ones that ended up on the smaller of the two mergerfs drives, the drive that will not be used in the final reconstituted Snapraid array.

A disadvantage of using LVM or mdadm in this scenario is that I'd need a third drive or networked storage to hold files while the two LVM or mdadm drives are reformatted to be used as stand-alone drives again. I think that makes mergerfs the clearly preferable solution here, and we now know it works for this purpose. It will require fewer temporary drives and it will require fewer subsequent file moves after recovery.

2

u/Nillows Jun 08 '26

Snapraid does not gracefully handle mergerfs mountpoints - and I don't even think the developers want it to because it sounds like a great way for people to overcomplicate an already delicate recovery structure. You would also need a parity drive or parity pool equal to, or larger than, the size of the entire mergerfs pool capacity to contain the XOR parity bits.

In the snapraid.conf, you want to list each drive's mountpoint individually, similar to how you must list them in individually in fstab to create the mergerfs pools.

Lastly, the more parity layers you have, the more robust your array is from multiple drive failure scenarios. By using mergerfs to reduce the amount of parity drives to 1, you would effectively be making your array less recoverable in multi drive failure situations, when you could have instead setup snapraid.conf to have parity 2 instead of one giant parity 1.

1

u/BootToggle Jun 08 '26 edited Jun 08 '26

Thanks for the detailed response.

I'm evidently having trouble conveying that this is not intended as some kind of weird permanent setup. Only a temporary measure to resolve the issue of a failed large data drive with no available replacement drive, and with a dead drive full of potentially lost files hanging in the balance.

1

u/Nillows Jun 08 '26

Here's what Claude Opus 4.8 Max has to say on the matter. I'm glad I asked because even I learned something.

Claude response below: read at your own peril.

Yeah, this is totally doable — and the tool you want is LVM, not mergerfs.

Quick why: mergerfs is fantastic as the pool you point your apps at, but as a single SnapRAID data disk it's the wrong layer. It scatters files across the underlying drives by policy and the inode/path behavior confuses SnapRAID's per-disk tracking. LVM is different — it glues several physical drives into one logical block device with a single filesystem on top, so SnapRAID just sees "one disk" and has no clue there are three drives hiding underneath. That's exactly the Frankenstein you're after.

Here's the gotcha that'll wreck your array if you miss it: SnapRAID requires your parity drive to be at least as big as your largest data drive. So when you pool spares together to stand in for the dead drive, the rebuilt volume must not end up bigger than your parity drive. If it does, it becomes the new "largest data drive," parity can no longer cover it, and SnapRAID won't protect it.

Concrete example: dead drive was 8TB, parity is 8TB, and you've got a 6TB and a 4TB in a drawer (10TB total). If you just concat both you get a 10TB data disk vs an 8TB parity = broken. So you only use part of that capacity — cap the pooled volume at ~8TB and leave the extra 2TB on the table.

The clean way to do that is to add both drives to the volume group but size the logical volume yourself instead of grabbing everything:

# ALWAYS confirm your device names first
lsblk
# wipe old signatures if these drives were used before
sudo wipefs -a /dev/sdX /dev/sdY

sudo pvcreate /dev/sdX /dev/sdY
sudo vgcreate rescue /dev/sdX /dev/sdY
# size it to ~match the dead drive but stay UNDER your parity drive.
# check parity's real byte size with: lsblk -b
sudo lvcreate -L 7.2T -n d3 rescue
sudo mkfs.ext4 /dev/rescue/d3
sudo mount /dev/rescue/d3 /mnt/disk3

That leaves the surplus unallocated and you're safe.

If you'd rather physically partition so the leftover space is actually usable for something else, it's the same idea from the other direction: partition the 4TB so only a ~2TB slice becomes a PV (pvcreate /dev/sdY1), leave the other partition for whatever you like, and size it so the 6TB + slice total stays just under your 8TB parity. Then lvcreate -l 100%FREE is fine because the VG itself is already capped. Either route, the end result is one ≤8TB block device mounted where your dead disk used to live. The key insight is identical: don't let the pool grow past parity, so only ever feed it part of that last drive.

Then point SnapRAID at it and rebuild just that one disk. Make sure the data d3 /mnt/disk3 line in your snapraid.conf matches the mount, then:

sudo snapraid -d d3 fix
sudo snapraid -d d3 check   # verify it came back clean

Two honest heads-ups before you rely on this:

  • With the disk spanned across multiple physical drives, if any one of them dies the whole logical disk is gone — you've basically multiplied the failure odds of that slot. Perfectly fine as a stopgap to get protected again today, but treat it as temporary until a real replacement drive shows up.
  • If you're running single parity, this is a great nudge to move to dual parity, since you're now leaning harder on that one parity disk.

1

u/BootToggle Jun 08 '26 edited 26d ago

This is good, thanks! I'm learning something also.

As mentioned, this temporary array would be torn down as soon as the affected files have been recovered and moved elsewhere, so no concerns about long-term consequences. One should never run 'snapraid sync' while this virtual drive is part of the array, for example.

The files might live on an external hard drive for a few hours, then the Snapraid array would be reconstituted with some (smaller) physical drive replacing the failed drive, and then the files redistributed back into the array. Only then should Snapraid sync be used.

1

u/BootToggle Jun 22 '26 edited Jun 22 '26

As an update, it turns out that mergerfs is sufficient for this problem, provided I use only the snapraid commands 'fix' and 'check' during the recovery. There are also some advantages to the mergerfs approach in comparision to the needs of LVM or mdadm. See some details of this in the comment from u/amadvance, and my reply, elsewhere on this posting.

I think where Claude gets it wrong is by raising objections to the permanent use of this mergerfs setup as if they also apply to the temporary file recovery case. And also ignoring the advantages that mergerfs actually provides over LVM for this temporary setup that is only used during the file recovery operation.

By my present understanding, I can do the whole job with two spare drives in the temporary mergerfs setup, one of which will end up being the final Snapraid replacement drive. By contrast, using LVM would require three spare drives and the final Snapraid replacement drive would have to be withheld from the temporary LVM setup. Using the LVM approach also requires more storage reconfigurations, more format operations, and more file copy operations. So, Claude misses the forest for the trees.

I really appreciate your help on understanding all this!

2

u/Drooliog Jun 08 '26

Combining a couple drives with LVM as suggested elsewhere would probably be easiest.

Failing that - and I haven't tried this myself - I reckon it'd be feasible to recover about half the array by manually targeting with filtering - e.g. snapraid fix -f DIR/

So long as SnapRAID doesn't complain about disk size from the outset, you only need a disk big enough for each run that encapsulates just the filtered data. Basically... run a fix -f DIR1/, move the data out, run it again: fix -f DIR2/ etc..

You might even be able to spread the recovered data back onto the other disks in your mergerfs pool, provided you have enough space there.

2

u/BootToggle Jun 08 '26 edited Jun 09 '26

That's an interesting take, thanks! And does address the real problem of allowing the Fix operations to complete without error.

To convey the scale of my problem, my Snapraid array includes two 18TB drives that I purchased just last year for <$10 USD per TB, used. I don't think I could replace them right now for anything less than $25 per TB, if that. This might not be a feasible purchase for me.

2

u/Drooliog Jun 08 '26

Yea storage prices are stupid.

I had an 8 year old 10TB die last month (very weird issue - no bad sectors, but whole swathes of very slow/delayed sectors) which I was able to replace with a shucked 14TB that I kinda had on standby, tho had to empty the drive first.

Luckily, I have another 14TB I could shuck if need be, but I'd have to juggle space elsewhere.

(In fact, I think I might test this ghetto recovery scenario in a VM to be sure SnapRAID isn't logic-bugged by seeing a small drive when doing fix -f. In theory, it should absolutely work!)

1

u/BootToggle Jun 08 '26 edited Jun 08 '26

I think that a lot of people may unexpectedly find themselves in this situation. And that is the reason I raise the question now, before I desperately need the answer.

I'd be very hard pressed to come up with $400 on short notice just because one of my larger drives failed. I'd actually be hard-pressed to even come up with money to replace one of my smaller drives, in today's market.

1

u/abubin2 Jun 08 '26

Use the smaller drives as data instead. No need to add another layer of virtual drive.

1

u/BootToggle Jun 08 '26 edited Jun 10 '26

The problem is that I can't make configuration changes to the array until I have recovered files previously held on the failed drive. Without a sufficiently large replacement drive, how can I recover files that the failed drive had contained?

If I put in a replacement drive that is too small and run 'snapraid fix', the recovery will fail when the designated replacement drive becomes full. If I just put in two new smaller drives and run 'snapraid sync' before recovering the files, those files will be lost. That is the problem I'm trying to solve, that I don't have a sufficiently large replacement drive for nominal file recovery.

I don't believe that I can directly recover files from a failed drive to two separate destination drives. But my hope is that creating a larger virtual drive in some fashion might get around that.