Designating Hot Spares in Your Storage Pool

The hot spares feature enables you to identify disks that could be used
to replace a failed or faulted device in one or more storage pools. Designating
a device as a hot spare means that the device is not
an active device in the pool, but if an active device in the pool fails, the
hot spare automatically replaces the failed device.

Devices can be designated as hot spares in the following ways:

When the pool is created with the zpool create command.

After the pool is created with the zpool add command.

The following example shows how to designate devices as hot spares when
the pool is created:

A hot spare cannot be removed if it is currently used by a storage pool.

Consider the following when using ZFS hot spares:

Currently, the zpool remove command can
only be used to remove hot spares, cache devices, and log devices.

To add a disk as a hot spare, the hot spare must be equal
to or larger than the size of the largest disk in the pool. Adding a smaller
disk as a spare to a pool is allowed. However, when the smaller spare disk
is activated, either automatically or with the zpool replace command,
the operation fails with an error similar to the following:

cannot replace disk3 with disk4: device is too small

Activating and Deactivating Hot Spares in Your Storage
Pool

Hot spares are activated in the following ways:

Manual replacement – You replace a failed device in
a storage pool with a hot spare by using the zpool replace command.

Automatic replacement – When a fault is detected, an
FMA agent examines the pool to determine if it has any available hot spares.
If so, it replaces the faulted device with an available spare.

If
a hot spare that is currently in use fails, the FMA agent detaches the spare
and thereby cancels the replacement. The agent then attempts to replace the
device with another hot spare, if one is available. This feature is currently
limited by the fact that the ZFS diagnostic engine only generates faults when
a device disappears from the system.

If you physically replace a failed device with an active spare, you
can reactivate the original device by using the zpool detach command
to detach the spare. 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.

You can manually replace a device with a hot spare by using the zpool
replace command. See Example 4–8.

A faulted device is automatically replaced if a hot spare is available.
For example:

Example 4–10 Detaching a Failed Disk and Using the Hot Spare

If you want to replace a failed disk by temporarily or permanently swap
in the hot spare that is currently replacing it, then detach the original
(failed) disk. If the failed disk is eventually replaced, then you can add
it back to the storage pool as a spare. For example: