Last Updated: September 30, 2021
·
15.35K
· phaus

creating a mirrored ZFS Pool out of a single-disk rpool

After a fresh Installation, a rpool may contain only one disk:

root@zfs-test:/# zpool status
  pool: rpool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          c0t0d0s0  ONLINE       0     0     0

Make sure, you have other disk to use (in this case c0t1d0) and that they have the same size - or could at least contain slices of the same size.

root@zfs-test:/# format < /dev/null
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c0t0d0 <ATA-VBOXHARDDISK-1.0 cyl 5218 alt 2 hd 255 sec 63>
          /pci@0,0/pci8086,2829@d/disk@0,0
       1. c0t1d0 <ATA-VBOXHARDDISK-1.0 cyl 5219 alt 2 hd 255 sec 63>
          /pci@0,0/pci8086,2829@d/disk@1,0
Specify disk (enter its number):

Copy the partition config of the specific slice (if used in the ZPool).

root@zfs-test:/# prtvtoc /dev/rdsk/c0t0d0s0 | fmthard -s - /dev/rdsk/c0t1d0s0
fmthard: Partition 2 specifies the full disk and is not equal
full size of disk.  The full disk capacity is 83843235 sectors.

Attach the Disk to the existing pool (don't use Add, since that would create a stripped/Raid0 Pool)

root@zfs-test:/# zpool attach -f rpool c0t0d0s0 c0t1d0s0
Make sure to wait until resilver is done before rebooting.

Check, that everything went well and wait until the resilvering is finished.

root@zfs-test:/# zpool status
  pool: rpool
 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.
  scan: resilver in progress since Wed Aug 20 22:49:09 2014
    1,40G scanned out of 2,28G at 160M/s, 0h0m to go
    1,40G resilvered, 61,62% done
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         ONLINE       0     0     0
          mirror-0    ONLINE       0     0     0
            c0t0d0s0  ONLINE       0     0     0
            c0t1d0s0  ONLINE       0     0     0  (resilvering)