Pcornel
Linux · RAID

Software RAID

Cheat sheet · https://pcornel.dk/topic.php?topic=2769

Back to the Topic

Answer

Linux software RAID (md, managed with mdadm) builds arrays from disks or partitions in the kernel: /dev/md0 with levels 0, 1, 5, 6 and 10. Configuration is stored in member superblocks and /etc/mdadm.conf.

Remember

Save the array definition (mdadm --detail --scan >> /etc/mdadm.conf or /etc/mdadm/mdadm.conf) and rebuild the initramfs so arrays assemble at boot. Enable mdmonitor for alerts. Boot disks in RAID 1 need the bootloader on every member.

First checks

  • cat /proc/mdstat — md arrays and sync status
  • mdadm --detail /dev/md<n> — array state and members
  • mdadm --examine /dev/<dev> — member superblock
  • smartctl -H /dev/<disk> — disk health

Commands

mdadm
mdadm --create /dev/md0 --level=1 --raid-devices=2 --bitmap=internal /dev/sda1 /dev/sdb1
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
mdadm --monitor --scan --test --oneshot

Verify in this order

members with superblocks → mdadm assembles at boot → /dev/mdN → filesystem; mdmonitor watches

Where it usually breaks

First mismatch in hardware/block device → kernel driver/mapper/RAID/LVM → filesystem → mount namespace/options → path permissions/MAC → consumer I/O; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2769

Confirmation

Confirm action

Continue?