Adding Mirrored Disk to Existing ZFS Pool

Great thing about ZFS is that even with a single disk you get some benefits – data integrity being the most important. And all ZFS commands work perfectly well, for example status:

# zpool status
pool: Data.Tertiary
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
Data.Tertiary ONLINE 0 0 0
diskid/DISK-XXX.eli ONLINE 0 0 0

However, what if one disk is not sufficient any more? It is clear zpool add can be used to create striped pool for higher speeds. And it is clear we can add another device to make a three way mirror. But what if we want to convert solo disk to mirror configuration?

Well, in that case we can get creative with attach command giving it both disks as an argument:

# zpool attach Data.Tertiary diskid/DISK-XXX.eli diskid/DISK-YYY.eli

After a few seconds, our mirror is created with all our data intact:

# zpool status
pool: Data.Tertiary
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
config:
NAME STATE READ WRITE CKSUM
Data.Tertiary ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
diskid/DISK-XXX.eli ONLINE 0 0 0
diskid/DISK-YYY.eli ONLINE 0 0 0 (resilvering)

PS: Yes, I use encrypted disks from /dev/diskid/ as I used them in previous ZFS examples. If you want plain devices, just use ada0 and companions instead.

3 thoughts to “Adding Mirrored Disk to Existing ZFS Pool”

  1. Thanks, this was the info I was looking for! “zfs add disk to pool as mirror” did find you

  2. When I try this, I get an error saying, “can only attach to mirrors and top-level disks”. The current output of “zpool status” looks just like yours (the first one). Have you seen that?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.