Introduction
RAID combines devices for performance, availability, or both. RAID is not a backup: deletion, corruption, compromise, and array loss can affect every member.
What you should be able to do after this lesson:
- Compare RAID 0, 1, and 5.
- Create and inspect an md array.
- Monitor synchronization and degraded state.
- Fail, remove, and replace a member safely.
- Assemble an existing array and understand persistent metadata.
Big Idea: Separate the Array from the Data Above It
Linux software RAID creates one md block device from several members. Partition tables, LVM, and filesystems normally sit above that md device:
member devices -> /dev/md0 -> optional LVM -> filesystem -> mount point
Replacing a member repairs redundancy at the array layer. It does not repair corrupted files inside the filesystem and does not restore deleted data.
RAID Levels
- RAID 0: striping, no redundancy, capacity is the sum of members.
- RAID 1: mirroring, survives member failure while a good copy remains.
- RAID 5: distributed parity, requires at least three members and normally survives one member failure.
RAID 5 rebuilds are I/O intensive and expose the remaining members to additional risk. Capacity, fault tolerance, and write performance must all be considered.
Inspect Devices First
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
wipefs /dev/<member>
Use equally sized partitions or devices when practical. Older partitioning conventions used type 0xFD for Linux RAID autodetection; modern md metadata carries assembly information.
Create an Array
Example RAID 1:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
cat /proc/mdstat
sudo mdadm --detail /dev/md0
After creation, build the filesystem on /dev/md0, not on an individual member.
Persistent Assembly
Scan array metadata and store the result in the distribution's mdadm.conf location:
sudo mdadm --detail --scan
The configuration may be /etc/mdadm.conf or /etc/mdadm/mdadm.conf. Rebuild the initramfs if the root or boot path depends on the array.
Replace a Failed Member
sudo mdadm /dev/md0 --fail /dev/sdb1
sudo mdadm /dev/md0 --remove /dev/sdb1
sudo mdadm /dev/md0 --add /dev/sdd1
watch cat /proc/mdstat
Confirm the correct failed member before removal. Do not remove a healthy member from an already degraded array.
Stop and Assemble
sudo umount /mountpoint
sudo mdadm --stop /dev/md0
sudo mdadm --assemble --scan
Stop users and unmount filesystems before stopping an array. --force can make a damaged situation worse and should follow a documented recovery decision.
Monitoring
Monitor /proc/mdstat, mdadm --detail, system logs, and device health. Configure notifications so degraded arrays are not discovered only after another failure.
Guided Practice: Design and Observe a Lab Array
Use disposable virtual disks or loop devices, never production storage. Plan a RAID 1 array and write down the expected state transitions:
sudo mdadm --create /dev/md/lpic-lab --level=1 --raid-devices=2 \
/dev/<lab-member-a> /dev/<lab-member-b>
watch cat /proc/mdstat
sudo mdadm --detail /dev/md/lpic-lab
After synchronization, identify:
- array UUID and metadata version
- active and working device counts
- member role numbers
- whether a bitmap is present
Simulate a member failure only in the disposable array, remove it, add a replacement, and watch recovery. Verify that the filesystem remains mounted and readable during degraded operation, then confirm that redundancy returns.
Troubleshooting Scenario
After reboot, both member partitions exist but /dev/md0 does not. Their md metadata is intact, while the initramfs lacks the array configuration required for early assembly.
Use mdadm --examine to confirm member identity, assemble by metadata, generate the correct mdadm.conf entry, and rebuild the initramfs if the root or boot path depends on the array. Creating a new array with --create risks overwriting metadata and is not the first recovery step.
Exam Focus
- RAID 0 provides no redundancy; RAID 1 mirrors; RAID 5 distributes parity.
- Know
mdadm,mdadm.conf,/proc/mdstat, and historical partition type0xFD. - Distinguish create, assemble, fail, remove, add, stop, and monitor operations.
- RAID availability does not replace independent, tested backups.
Recap
- RAID availability and backup solve different risks.
- Create filesystems on the md device.
- Persist assembly metadata and include it in early boot when required.
- A degraded array should be repaired promptly and carefully.
Test Your Knowledge
Complete the quiz to assess your understanding of this course's concepts.
