I wanted to replace a disk in a ZFS pool (RAIDZ1) with itself. Or in other words, format the disk and have ZFS resilver it.
The general advice is to offline
the device and replace
it with itself:
zpool offline POOL_NAME DEVICE_NAMEfdisk /dev/disk/by-id/DISK_ID # write empty GPT partition tablezpool replace POOL_NAME DEVICE_NAME /dev/disk/by-id/DISK_ID
This doesn’t work however. I got an error message that was something like:
cannot replace <device> with <device>: <device> is busy
Solution
In order to make ZFS happy when replacing a device with itself, you need to run labelclear
on it before erasing the ZFS metadata:
zpool offline POOL_NAME DEVICE_NAMEzpool labelclear -f DEVICE_NAME # need to -f because it's still part of an active poolfdisk /dev/disk/by-id/DISK_ID # write empty GPT partition tablezpool replace POOL_NAME DEVICE_NAME /dev/disk/by-id/DISK_ID