Convert FreeBSD ZFS two-disk unmirrored pool to mirrored

freebsdraidzfs

I have a storage pool aptly called storage with two disks in it. Originally, I wanted to add the second disk as a mirror but did the ZFS newbie mistake of using zpool add storage <device> instead of zpool attach storage <device>.

Every attempt to remove or detach the second device from the pool fails, because ZFS complains about not having redundant drives. After reading into it, I understand the issue and why this is. However, I wasn't able to find a solution how to either remove the drive to re-attach it or simply convert the whole pool to mirrored instead of striped. I'm also kind of puzzled by the fact there seems to be no straight-forward way to do it.

Is there a way to achieve this short of destroying and recreating the pool? I'd rather not need to buy another 4TB drive and copy all that data over.

Best Answer

Unfortunately, at this point you basically have two good options:

  • Destroy and recreate the pool with the intended configuration, then restore your data from a restoration copy
  • Get two more drives (minimum same size as each respective one you already have) and expand your pool to two mirrored pairs instead of two single disks

The latter can be performed in-place, and has the bonus of providing you with additional storage space, but requires you to purchase more hardware (which you said in the question that you don't want to do). The former cannot be done in-place, but provides you with a good opportunity to test your restoration strategy (you do have a restoration strategy, I presume?).

As you have found out, it's not possible to remove a JBOD component in a ZFS pool. By adding rather than attaching the new drive, you created a JBOD situation with multiple disks.

If you do go with expanding the pool, I suggest strongly considering expanding into raidz2 instead of two mirrored pairs. You get (essentially) the same usable storage capacity, but the ability to survive the failure of any two of the drives, as opposed to only one per pair. You can create a raidz2 vdev with two sparse files and then delete those files before replacing them with drives you are migrating data from, to migrate from your current situation of 2-disk JBOD to 4-disk RAIDZ2 only adding two more disks.

Related Question