2

I'm getting ready to add another server to my home network. I currently have one storage drive for it. I want to add another one to mirror the first drive, but can't purchase the second drive for a couple of weeks to a month. I want to use ZFS on the mirrored storage drives. Can I start copying data to my single storage drive, later add the second drive, and have ZFS copy the first drive's data to the second drive in a mirror?

3

Yes, adding a second drive to mirror an existing vdev is pretty easy.

Lets say you created your pool like this. I use GPT partition labels like zfs-d1 to make the names nice/reliable.

zpool create zfs1 -o ashift=12 -m none /dev/disk/by-partlabel/zfs-d1

  pool: zfs1
 state: ONLINE
config:

    NAME         STATE     READ WRITE CKSUM
    zfs1         ONLINE       0     0     0
      zfs-d1     ONLINE       0     0     0

Adding another drive to the be a mirror for zfs-d1 is easy. We are going to give the new one the label zfs-d2

zpool attach zfs1 /dev/disk/by-partlabel/zfs-d1 /dev/disk/by-partlabel/zfs-d2

Which I believe should result in a pool that looks like this. You would need to wait a while for things to resync, but you really don't have to do much.

  pool: zfs1
 state: ONLINE
config:

    NAME         STATE     READ WRITE CKSUM
    zfs1         ONLINE       0     0     0
      mirror-0   ONLINE       0     0     0
        zfs-d1   ONLINE       0     0     0
        zfs-d2   ONLINE       0     0     0

Anyway I strongly suggest you try this in a VM really quick. Build up a VM add a few small virtual disk and just try adding them to a pool. Testing in a VM will let you have a place to try things out, and if you screw up you lose nothing.

| improve this answer | |
  • 2
    @marcerickson As for the above answer, be sure to attach the new device, rather than adding it. – shodanshok Dec 5 '18 at 8:51
  • VM is a good idea. Thanks. I'm new to the server world - and the Linux world. – marcerickson Dec 5 '18 at 17:57
  • Just to be sure: will it also work when zfs-d1 is encrypted (native ZFS encryption on the dataset inherited by the pool)? – Alex Nov 1 '19 at 21:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.