ZFS - replacing a disk with itself

I have a server which had a problem starting up such that not all the disks that make up the ZFS raidz2 array were available. Consequently the array started up in a degraded state, like this:

root@mymachine:~# zpool status MyPool
  pool: MyPool
 state: DEGRADED
status: One or more devices could not be used because the label is missing or
	invalid.  Sufficient replicas exist for the pool to continue
	functioning in a degraded state.
action: Replace the device using 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-4J
config:

	NAME                     STATE     READ WRITE CKSUM
	MyPool                   DEGRADED     0     0     0
	  raidz2-0               DEGRADED     0     0     0
	    nvme0n1              ONLINE       0     0     0
	    nvme1n1              ONLINE       0     0     0
	    8541234552485432110  FAULTED      0     0     0  was /dev/nvme2n1p1
	    nvme3n1              ONLINE       0     0     0

errors: No known data errors

This missing disk is not actually faulty, but it needs to be added back to the array to provide redundancy.

zdb shows the disk with the right GUID (8541234552485432110) and path (/dev/nvme2n1p1), but the disk is marked not_present. Using zdb -l /dev/nvme2n1p1 shows that the metadata is present on the physical disk, as you would expect, but it is clearly out of date.

To repair the array, you need to replace the disk with itself, like this:

root@mymachine:~# zpool replace MyPool /dev/nvme2n1p1

The state of the array now shows the disk being reconstructed. At the end, it'll show the disk as nvme2n1p1. It was originally added as a whole disk, nvme2n1, but this replacement has changed the configuration to a partition instead. This is a cosmetic change.

root@mymachine:~# zpool status MyPool
  pool: MyPool
 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 20 13:49:20 2026
	1.90T / 18.0T scanned at 97.5G/s, 0B / 18.0T issued
	0B resilvered, 0.00% done, no estimated completion time
config:

	NAME                       STATE     READ WRITE CKSUM
	MyPool                     DEGRADED     0     0     0
	  raidz2-0                 DEGRADED     0     0     0
	    nvme0n1                ONLINE       0     0     0
	    nvme1n1                ONLINE       0     0     0
	    replacing-2            DEGRADED     0     0     0
	      8541234552485432110  FAULTED      0     0     0  was /dev/nvme2n1p1/old
	      nvme2n1p1            ONLINE       0     0     0
	    nvme3n1                ONLINE       0     0     0

If it had given the error, "/dev/nvme2n1p1 is part of the active pool, MyPool", then the procedure would be this instead:

root@mymachine:~# zpool offline MyPool 8541234552485432110
root@mymachine:~# zpool labelclear -f /dev/nvme2n1p1
root@mymachine:~# zpool replace -f MyPool 8541234552485432110 /dev/nvme2n1p1