Step‑by‑Step Guide to Building and Managing RAID10 with mdadm on Linux
This tutorial explains RAID concepts, compares RAID levels, and provides a complete, command‑by‑command walkthrough for creating, monitoring, repairing, and removing a software RAID10 array on a Linux server using mdadm.
What is RAID?
RAID (Redundant Array of Independent Disks) aggregates multiple physical disks into a single logical volume, providing higher I/O throughput, fault tolerance, and cost‑effective redundancy.
Key Benefits
Parallel reads/writes improve I/O performance.
Redundant layouts (mirroring, parity) increase data durability.
Shared storage reduces overall hardware cost.
Common RAID Levels
RAID 0 – Minimum 2 disks, striping for performance, no redundancy.
RAID 1 – Minimum 2 disks, mirroring for fault tolerance, 50 % usable capacity.
RAID 5 – Minimum 3 disks, block‑level parity, balanced read performance and fault tolerance.
RAID 6 – Minimum 4 disks, double parity, higher fault tolerance, slower writes.
RAID 10 – Minimum 4 disks, mirrored pairs striped together, high performance and redundancy, 50 % usable capacity.
Hardware vs. Software RAID
Hardware RAID uses a dedicated RAID controller card, offering OS‑independent operation and generally higher stability. Software RAID (e.g., mdadm) is implemented in the operating system, providing flexibility at the cost of additional CPU overhead.
Software RAID 10 Setup on a CentOS/RHEL System
1. Environment preparation
Attach four new disks (e.g., /dev/sdd, /dev/sde, /dev/sdf, /dev/sdg) and verify their presence:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 18G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
sdd 8:48 0 10G 0 disk
sde 8:64 0 10G 0 disk
sdf 8:80 0 10G 0 disk
sdg 8:96 0 10G 0 disk2. Install mdadm
# yum install -y mdadm3. Create the RAID 10 array
Use mdadm with the following options: -C – create a new array. -v – verbose output. -a yes – automatically create the device node. -n 4 – number of active devices. -l 10 – RAID level 10.
# mdadm -Cv /dev/md0 -a yes -n 4 -l 10 /dev/sdd /dev/sde /dev/sdf /dev/sdg
mdadm: layout defaults to n2
mdadm: chunk size defaults to 512K
mdadm: size set to 10476544K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.4. Verify the array
# fdisk -l /dev/md0
Disk /dev/md0: 21.5 GB, 21455962112 bytes, 41906176 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes5. Create a filesystem
# mkfs.xfs /dev/md0
meta-data=/dev/md0 isize=512 agcount=16, agsize=654720 blks
... (standard XFS output omitted)6. Mount and test
# mount /dev/md0 /md0_disk
# df -h
# touch /md0_disk/test.txt
# ls /md0_disk7. Configure automatic mount at boot
# echo "/dev/md0 /md0_disk xfs defaults 0 0" >> /etc/fstab8. Simulate a disk failure
# mdadm /dev/md0 -f /dev/sdd
mdadm: set /dev/sdd faulty in /dev/md09. Check degraded state
# mdadm -D /dev/md0
... State: clean, degraded
Active Devices : 3
Failed Devices : 110. Recover the failed disk
Unmount the array (if it is in use): # umount /dev/md0 Optionally reboot the server to ensure no processes hold the device.
Add the replacement disk:
# mdadm /dev/md0 -a /dev/sdd # mdadm -D /dev/md0
... State: clean, degraded, recovering
Spare Devices : 1
Rebuild Status : 6% complete11. Final verification
# mdadm -D /dev/md0
... State: clean
Active Devices : 4
Working Devices : 4
Failed Devices : 012. Remove the software RAID
Unmount the array: # umount /dev/md0 Stop the mdadm device: # mdadm -S /dev/md0 Erase superblocks on each member disk:
# mdadm --misc --zero-superblock /dev/sdd
# mdadm --misc --zero-superblock /dev/sde
# mdadm --misc --zero-superblock /dev/sdf
# mdadm --misc --zero-superblock /dev/sdgDelete the mdadm configuration file (if present): # rm -f /etc/mdadm.conf Remove the corresponding line from /etc/fstab to stop automatic mounting.
After completing these steps the system returns to a normal, non‑RAID state.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
