Interview Prep/Linux/Storage, disks and filesystems

A disk in your RAID 1 array failed. How do you replace it without downtime?

IntermediateScenarioStorage, disks and filesystems
Answer

Situation read → Degraded mirror; swap and resync.

What I'd do →

cat /proc/mdstat                         # [U_] means degraded
sudo mdadm /dev/md0 --fail /dev/sdc --remove /dev/sdc
# physically replace the disk (hot-swap bay)
sudo sfdisk -d /dev/sdb | sudo sfdisk /dev/sdc   # copy partition table if partitioned
sudo mdadm /dev/md0 --add /dev/sdc
watch cat /proc/mdstat

If the array is also the boot disk, reinstall the bootloader on the new disk.

Why → The array keeps serving from the healthy disk while it rebuilds.

Interview tip → Check smartctl -a on the surviving disk; a second failure during rebuild is the real risk.

All Linux questions Roadmap: Linux

More on Storage, disks and filesystems