Sub topic 14
Hot-Swappable Drives and Hot Spares
This chapter assumes you know what RAID 1, RAID 5, RAID 6, and RAID 10 do, and that a failed drive in a redundant array leaves it running in a degraded state. Here you will learn how a failed drive is replaced without shutting the system down, and how a spare drive can start that replacement automatically.
Three ways to replace a drive
The words "hot," "warm," and "cold" describe the state of the system when a part is swapped.
| Method | System state during swap | Typical use |
|---|---|---|
| Hot swap | Powered on and running | Servers and NAS units with drive bays |
| Warm swap | Powered on but idle or suspended | Some older or specialized systems |
| Cold swap | Powered off | Ordinary desktops and laptops |
A hot-swappable drive is a drive you can remove and insert while the system runs, with no shutdown and no data loss on the rest of the array. The exam usually contrasts this with a cold swap, where you power down first.
What makes a drive hot-swappable
The drive itself is rarely the deciding factor. The enclosure and controller must support it.
- Backplane. A circuit board at the back of the drive bays. It carries power and data to each slot and keeps power sequencing safe when a drive is inserted.
- Drive carrier (tray). A caddy the drive screws into. It slides into the bay and often has a latch and status LEDs.
- Controller support. The RAID controller, or the SATA controller in AHCI mode with hot plug enabled, must tolerate a device appearing and disappearing.
- Interface. SAS and SATA drives are commonly hot-swapped in server bays. U.2 NVMe drives can be too. A bare M.2 stick is not designed for it.
Plugging a loose SATA drive into a desktop's power and data cables while it runs is risky. The standard connectors can allow it, but the board and operating system may not handle it cleanly. Do not assume a desktop supports hot swap.
Hot spares
A hot spare is an extra drive installed in the array's enclosure, powered on and idle. When a member drive fails, the controller automatically starts rebuilding the lost data onto the spare. No technician has to act first.
A cold spare is a replacement drive kept on a shelf. Someone must fetch it, install it, and start the rebuild. The array stays degraded until then.
Hot spares come in two common forms:
- Dedicated hot spare: assigned to one specific array.
- Global hot spare: available to any array on the controller. It takes over for the first array that loses a drive.
A spare does not add usable capacity while it waits. If you build RAID 5 from four 2 TB drives plus one hot spare, usable capacity is (4 − 1) × 2 = 6 TB, the same as without the spare. The spare also has to be at least as large as the drive it replaces. Spares are meaningful only for redundant levels (1, 5, 6, 10). RAID 0 has nothing to rebuild from.
What happens during a failure
The array moves through predictable states. The time spent degraded is the risky window.
- A drive fails and the controller marks it offline. The array is degraded but still serves data.
- With a hot spare, the controller begins the rebuild at once. Without one, it waits for a replacement.
- For RAID 1 and RAID 10, the controller copies data from the surviving mirror partner. For RAID 5 and 6, it recomputes missing blocks from parity, as in the XOR example from the RAID 5 chapter.
- When the rebuild finishes, the array is optimal again. The spare is now a regular member.
- The technician replaces the failed drive. It usually becomes the new hot spare, though some controllers instead copy data back to it.
Performance drops during a rebuild because every surviving drive is being read heavily. That also stresses older drives, which is why a second failure during a rebuild is a real risk.
Why the rebuild window matters
Rebuild time grows with drive size. A rough estimate divides the amount of data by the sustained rebuild rate.
def rebuild_hours(size_tb, rate_mb_s):
"""Estimate rebuild time in hours for one drive."""
megabytes = size_tb * 1_000_000
return megabytes / rate_mb_s / 3600
print(round(rebuild_hours(4, 150), 1)) # 7.4
print(round(rebuild_hours(8, 100), 1)) # 22.2Real rebuilds are often slower because the array also serves users. A 22-hour window leaves a RAID 5 array with no redundancy for nearly a day. Larger drives are one reason RAID 6 is favored for big arrays. It survives a second failure during the window. A hot spare shortens the window by removing the delay before the rebuild starts. It does not make the rebuild itself faster.
Software RAID example on Linux
Software RAID can also use spares. This example uses mdadm, the Linux software RAID tool. It builds a three-drive RAID 5 with one spare, then simulates a failure. The device names are examples, so check yours first, and run these commands only on empty test drives.
# Create RAID 5 with 3 active drives and 1 spare
sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 --spare-devices=1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
# Simulate a failure and remove the bad drive
sudo mdadm /dev/md0 --fail /dev/sdc --remove /dev/sdc
# Watch the spare rebuild
cat /proc/mdstatThe --fail step marks /dev/sdc as bad. The kernel then pulls /dev/sde in from the spare list automatically. The /proc/mdstat file shows a progress bar for the rebuild.
Replacing a drive safely
- Identify the failed drive from the controller software or the bay's status LED, which is often amber or red. Do not pull a drive based on a guess.
- Confirm the array is degraded and not already failed. Pulling a healthy drive from a degraded RAID 5 destroys the array.
- Release the carrier and remove the failed drive. Wait for it to spin down if the bay does not do so automatically.
- Insert a replacement of equal or larger capacity, ideally the same type and speed.
- Confirm the controller sees the drive and shows rebuild activity.
Static discharge matters here. Handle drives by the carrier or edges and avoid touching the circuit board.
Hardware and software differences
A hardware RAID controller usually manages hot spares and hot-swap events on its own, with an LED and a management utility. Software RAID can do the same, but it depends on the operating system and on the motherboard's hot-plug support. The next chapter compares the two approaches in more detail.
Common mistakes
- Treating a hot spare as extra capacity. It adds none.
- Using a spare smaller than the array's drives. It cannot take over.
- Pulling the wrong drive from a degraded array.
- Assuming any SATA drive in any desktop is hot-swappable.
- Putting a hot spare in a RAID 0 setup.
Exercise
A server runs RAID 5 on four 4 TB drives plus one hot spare. One drive fails. (a) What is the usable capacity before the failure? (b) What does the controller do next? (c) Why is the array still at risk until the rebuild ends?
Show answer
(a) Usable capacity is (4 − 1) × 4 TB = 12 TB. The spare adds nothing. (b) The controller marks the failed drive offline, activates the hot spare, and rebuilds the missing data onto it from parity while the array keeps serving users. (c) The array is degraded and has no redundancy. A second drive failure during the rebuild would destroy the RAID 5 array, and rebuilding stresses the surviving drives.
Exercise
A technician must replace a failed drive in a rack server without shutting it down. Name two things that must support this, and name one step to take before pulling a drive.
Show answer
The drive bay backplane and carrier, and the RAID controller, must support hot swap. Before pulling a drive, identify the failed drive from the status LED or management software and confirm the array is degraded, not already failed. This avoids removing a healthy drive.