disko icon indicating copy to clipboard operation
disko copied to clipboard

Allow setting up degraded ZFS pools

Open mweinelt opened this issue 2 years ago • 4 comments

I had a raid crash on me and needed to get up again quickly. I only had one disk to start with, but a second one was ordered already. The plan was to create a ZFS mirror, but that requires me to have two disks in place. Or does it?

With help of a sparse file mounted as a loopback device we can create a degraded ZFS mirror.

# truncate -s <size of other disk> /tmp/disk.raw
# losetup -f --show /tmp/disk.raw
/dev/loop1
# zfs create tank mirror ... /dev/disk/by-label/root-a /dev/loop1
# zfs offline tank /dev/loop1

Now when the second disk arrives I can replace the dummy disk and complete my raid1.

The same could be done with raidz1 (one sparse file max) or raidz2 (two sparse files max).

In disko this would probably best fit into the zpool section.

mweinelt avatar Jan 11 '23 03:01 mweinelt

Would it not be cleaner if you use zpool attach instead, once you have second disk? So you start with a single disk zpool and later you can migrate manually.

Mic92 avatar Jan 11 '23 08:01 Mic92

Ah, indeed. That should work for going from a single disk to an n-way mirror. But that won't work for setting up raidz setups.

mweinelt avatar Jan 11 '23 14:01 mweinelt

Still feels a bit adhoc/hacky to support this feature but maybe we can justify by having some other feature that just allows to setup a loopback mount with losetup to make it possible?

Mic92 avatar Jan 11 '23 18:01 Mic92

Personally I would have had a use for this as well right now. Adding something like a createAsDegraded option would be super cool.

Still feels a bit adhoc/hacky to support this feature but maybe we can justify by having some other feature that just allows to setup a loopback mount with losetup to make it possible?

I think it wouldn't feel as hacky if it was well-integrated. Meaning, if you remove createAsDegraded or set it to false and add the required devices, they are automatically added to the existing pool when running disko again.

Adding a loopback type seems like a feature that might be useful separately.

iFreilicht avatar Sep 20 '24 19:09 iFreilicht