How to remove faulted disk from ZFS pool once spare replacement done

Will Dennis asked:

I have a ZFS pool in the current state:

[[email protected] ~]# zpool status
  pool: zdata
 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'.
  scan: scrub repaired 0 in 186h53m with 0 errors on Sun Jan 27 20:53:44 2019

        NAME                                                  STATE     READ WRITE CKSUM
        zdata                                                 DEGRADED     0     0     0
          raidz3-0                                            DEGRADED     0     0     0
            ata-HGST_HUH728080ALE604_2EGWK97X                 ONLINE       0     0     0
            spare-1                                           DEGRADED     0     0     2
              ata-HGST_HUH728080ALE604_2EGWHSGX               UNAVAIL      0     0     0
              ata-HGST_HUH728080ALE604_2EGWD3WX               ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGGVUTX                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EHG14TX                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGWW4XX                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGW5A5X                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGWTPYX                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGWALNX                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGWNN1X                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGWG0BX                 ONLINE       0     0     0
            ata-HGST_HUH728080ALE604_2EGWWTGX                 ONLINE       0     0     0
          mirror-1                                            ONLINE       0     0     0
            ata-INTEL_SSDSC2BA100G3_BTTV5435005Y100FGN-part1  ONLINE       0     0     0
            ata-INTEL_SSDSC2BA100G3_BTTV54350016100FGN-part1  ONLINE       0     0     0
          ata-INTEL_SSDSC2BA100G3_BTTV5435005Y100FGN-part2    ONLINE       0     0     0
          ata-INTEL_SSDSC2BA100G3_BTTV54350016100FGN-part2    ONLINE       0     0     0
          ata-HGST_HUH728080ALE604_2EGWD3WX                   INUSE     currently in use

errors: No known data errors

As you can see, I have added the spare disk “ata-HGST_HUH728080ALE604_2EGWD3WX” via the command zpool replace zdata /dev/disk/by-id/ata-HGST_HUH728080ALE604_2EGWHSGX /dev/disk/by-id/ata-HGST_HUH728080ALE604_2EGWD3WX which has now created a spare-1 device with boths disks in it (was expecting the spare 2EGWD3WX drive to replace the dead 2EGWHSGX one.)

How do I remove the dead drive ata-HGST_HUH728080ALE604_2EGWHSGX now?

My answer:

To replace a failed disk with a hot spare, you do not need to zpool replace at all (and in fact this might cause you all sorts of grief later; I’ve never done this). Instead you are supposed to simply zpool detach the failed disk and the hot spare automatically replaces it.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.