How to attach a 2-device striped mirror to a pool

storagezfszfsonlinux

I have a single-drive pool consisting of a 2TB HDD.
I have two 1TB drives I can use in mirror – I'd like to add redundancy to my pool.

How can I attach these two drives as a single device so that they can be used as a striped mirror?

Let's call my 2TB drive is sda, the blank 1TB drives are sdb and sdc.

I tried: zfs attach tank sda sdb sdc but that says too many arguments.

I tried: zfs attach tank sda sdb but that says device is too small

I tried: zfs attach tank sda sdb+sdc but that says no such device in /dev

I tried: zfs attach tank sda sdb,sdc but that says no such device in /dev

I've read the manual and searched the web – I am out of ideas.

I guess I could try to create a new striped pool from these two 1TB drives, create a zvol inside and use that as a mirror for my primary pool, but this is probably going to give me not enough capacity for a mirror anyway, plus a lot of unneeded overhead.

How can I do this?

Best Answer

This can not be directly done via ZFS. From the man page:

Virtual devices cannot be nested, so a mirror or raidz virtual device can only contain files or disks. Mirrors of mirrors (or other combinations) are not allowed.

My suggestion is to create a new pool comprising the two 1 TB disks and use something as syncoid to frequently send the first pool's content to the new pool.

--- WARNING: clunky workaround below! Do NOT use if not REALLY sure!!! ---

Anyway, if you really want to add the two 1 TB disks as a mirror of the first 2 TB disks, a workaround can be tried. You can use device-mapper (in its LVM form) to concatenate the two disks and attach the resulting volume to the 2 TB device. For example:

pvcreate /dev/sdb
pvcreate /dev/sdc
vgcreate zvg /dev/sdb
vgextend zvg /dev/sdc
lvcreate zvg --name zdev -l +100%FREE
zpool attach tank /dev/sda /dev/zvg/zdev
zpool status

You can achieve a similar (even better) result with mdadm, creating a RAID0 device and attaching it to the zpool:

mdadm --create md127 --level=0 --raid-devices=2 /dev/sdb /dev/sdc
zpool attach tank /dev/sda /dev/md127
zpool status

This approach is not recommended. Use it at your own risk.