ZFS ZFS root, mirror, replacing faulty disk

Hello,
Doing this for a first time on live system, so please correct me if I'm doing something wrong. Also doing this on remote system, and it is quite hard to get there.

System description:
rootfs on zfs, only 2 disks, mirror

Disks: /dev/ada0, /dev/ada1(new disk, old disk not spinning, replaced)
Code:
# zpool status
    zroot                    DEGRADED     0     0     0
      mirror-0               DEGRADED     0     0     0
        ada0p3               ONLINE       0     0     0
        9258811949525251908  REMOVED      0     0     0  was /dev/ada1p3

# gpart show
=>        40  1953525088  ada0  GPT  (932G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048    16777216     2  freebsd-swap  (8.0G)
    16779264  1936744448     3  freebsd-zfs  (924G)
  1953523712        1416        - free -  (708K)

Here is what I would like to do to restore system functionality
1. Clone partition table:
# gpart backup ada0 | gpart restore -F /dev/ada1

2. put bootcode on a new disk:
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 /dev/ada1

3. replace disk in zfs:
# zpool replace zroot 9258811949525251908 /dev/ada1p3

then wait for resilver...
 
I used gpart backup / restore and that worked. No problem there.

Never used zpool replace, though. Ran zpool detach then zpool attach. But I think that in this case, it's equivalent (and more elegant).

Just a warning: after the new disk has been physically added, check twice which disk is ada0 and which is ada1.
 
Guys! Thank you so much for quick reply!
Now I fill myself more confident 👹
...
Code:
  pool: zroot
 state: DEGRADED
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 Fri Feb  8 20:07:59 2019
    16.5G scanned out of 55.9G at 30.4M/s, 0h22m to go
        16.5G resilvered, 29.59% done
config:

    NAME                       STATE     READ WRITE CKSUM
    zroot                      DEGRADED     0     0     0
      mirror-0                 DEGRADED     0     0     0
        ada0p3                 ONLINE       0     0     0
        replacing-1            REMOVED      0     0     0
          9258811949525251908  REMOVED      0     0     0  was /dev/ada1p3/old
          ada1p3               ONLINE       0     0     0

Looks OK.. ish :)
 
Back
Top