Skip to content
Search Oracle Linux

    Browse this documentation

    Software RAID (mdadm) in practice: building RAID1, simulating a disk failure online, and hot rebuilding

    The complete mdadm software-RAID operations loop: build → use → disk dies → rebuild online. Everything was measured on loopback devices (no real disks affected), and the method transfers directly to production disks.

    Terminal window
    dnf install -y mdadm
    mdadm --create /dev/md0 --level=1 --raid-devices=2 --run /dev/sdb /dev/sdc
    cat /proc/mdstat
    # md0 : active raid1 sdb[0] sdc[1]
    # 101376 blocks super 1.2 [2/2] [UU]

    [UU] = both disks healthy. A newly created array shows resync=PENDING — a background-sync backlog that does not block IO.

    Terminal window
    mdadm --detail /dev/md0 | grep -E "Raid Level|State|Active Devices"
    # Raid Level : raid1
    # State : clean, resyncing (PENDING)
    # Active Devices : 2

    The filesystem works as usual:

    Terminal window
    mkfs.ext4 /dev/md0 && mount /dev/md0 /mnt && echo ok > /mnt/t.txt

    The dead disk and hot rebuild (the main act)

    Section titled “The dead disk and hot rebuild (the main act)”
    Terminal window
    mdadm /dev/md0 --fail /dev/sdc # mark failed (simulating a bad disk)
    mdadm /dev/md0 --remove /dev/sdc # pull it out
    mdadm --detail /dev/md0 | grep -E "State|Active"
    # State : active, degraded, resyncing (PENDING)
    # Active Devices : 1

    The degraded state stays readable and writable (raid1 keeps serving from the single disk) — this is RAID1’s moment of value. Swap in a new disk:

    Terminal window
    mdadm /dev/md0 --add /dev/sdd # hot-insert and join
    mdadm --detail /dev/md0 | grep -E "State|Active"
    # State : active, rebuilding
    # Active Devices : 2 ← rebuilding online, no umount needed

    The rebuild completes back to [UU]. Service never interrupted throughout (measured: the ext4 mount stayed available).

    TaskCommand
    The global viewcat /proc/mdstat
    One array’s detailsmdadm --detail /dev/md0
    Which array owns a diskmdadm --examine /dev/sdb
    Persist the config (auto-assembly after reboot)mdadm --detail --scan >> /etc/mdadm.conf
    Trigger a full check manuallyecho check > /sys/block/md0/md/sync_action
    • Measured: the RAID1 full cycle (build/write/degrade/hot rebuild) on loopback devices (E3);
    • Not measured: real physical-disk hot-swap, RAID5/10 topologies, bitmap acceleration;
    • Sources: mdadm(8), OL10 storage documentation.