Activating and Deactivating Hot Spares in Your Storage Pool

You activate hot spares in the following ways:

  • Manual replacement – Run the zpool replace command to replace a failed device. When a new device is inserted to replace the failed disk, you activate the new device by detaching the spare.

  • Automatic replacement – An FMA agent detects a fault, determines spare availability, and automatically replaces the faulted device. A hot spare also replaces a device in the UNAVAIL state.

    If you set the autoreplace pool property to on, the spare is automatically detached and returned to the spare pool when the new device is inserted and the online operation completes.

To deactivate a hot spare, perform one of the following actions:

  • Remove the hot spare from the storage pool.

  • Detach the hot spare after physically replacing a failed disk. See Example 4-12.

  • Swap in another hot spare either temporarily or permanently. See Example 4-13.

Example 4-12 Detaching a Hot Spare After the Failed Disk Is Replaced

This example assume the following configuration:

  • In system1's mirror-1 configuration, disk c0t5000C500335BA8C3d0 has failed. The following partial output shows the status of mirror-1:

    $ zpool status system1
    .
      mirror-1                 DEGRADED     0     0     0
        c0t5000C500335BD117d0  ONLINE       0     0     0
        c0t5000C500335BA8C3d0  UNAVAIL      0     0     0Failed disk
  • The pool's spare c0t5000C500335E106Bd0 is automatically activated to replace the failed disk.

  • You physically replace the failed disk with a new device c0t5000C500335DC60Fd0.

The example begins with reconfiguring the pool with the new device. First, you run zpool replace to inform ZFS about the removed device. Then, if necessary, you run zpool detach to deactivate the spare and return it to the spare pool. The example ends with displaying the status of the new configuration and performing the appropriate FMA steps for fault devices, as shown in Step 6 of How to Replace a Device in a Storage Pool.

$ zpool replace system1 c0t5000C500335BA8C3d0
$ zpool detach system1 c0t5000C500335E106Bd0
$ zpool status system1
.
.
  mirror-1                 ONLINE       0     0     0
    c0t5000C500335BD117d0  ONLINE       0     0     0
    c0t5000C500335DC60Fd0  ONLINE       0     0     0Replacement device
  spares
    c0t5000C500335E106Bd0    AVAIL                   Deactivated spare

$ fmadm faulty
$ fmadm repaired zfs://pool=name/vdev=guid

Example 4-13 Detaching a Failed Disk and Using the Hot Spare

Instead of a new replacement device, you can use the spare device as a permanent replacement instead. In this case, you simply detach the failed disk. If the failed disk is subsequently repaired, then you can add it to the pool as a newly designated spare.

This example uses the same assumptions as Example 4-12.

  • The mirror-1 configuration of the pool system1 is in a degraded state.

    $ zpool status system1
    .
      mirror-1                 DEGRADED     0     0     0
        c0t5000C500335BD117d0  ONLINE       0     0     0
        c0t5000C500335BA8C3d0  UNAVAIL      0     0     0Failed disk
  • The pool's spare c0t5000C500335E106Bd0 is automatically activated to replace the failed disk.

The example begins with detaching the failed disk that has been replaced by the spare.

$ zpool detach system1 c0t5000C500335BA8C3d0
$ zpool status system1
.
.
  mirror-1                 ONLINE       0     0     0
    c0t5000C500335BD117d0  ONLINE       0     0     0
    c0t5000C500335E106Bd0  ONLINE       0     0     0Spare replaces failed disk

errors: No known data errors

Subsequently, you add the repaired disk back to the pool as the spare device. You complete the procedure by performing the appropriate FMA steps for fault devices.

$ zpool add system1 spare c0t5000C500335BA8C3d0
$ zpool status system1
.
.
  mirror-1                 ONLINE       0     0     0
    c0t5000C500335BD117d0  ONLINE       0     0     0
    c0t5000C500335E106Bd0  ONLINE       0     0     0Former spare
  spares
    c0t5000C500335BA8C3d0    AVAIL                   Repaired disk as spare

errors: No known data errors

$ fmadm faulty
$ fmadm repaired zfs://pool=name/vdev=guid