Software RAID with mdadm
Linux software RAID uses mdadm to group multiple disks into a fault-tolerant volume. This guide applies to HolyCloud dedicated servers where you manage disks (RAID 1 mirror or RAID 5 with parity).
Prerequisites
- Dedicated server with at least two identical disks (RAID 1) or three+ (RAID 5)
- IPMI/KVM access if system no longer boots
- Full backup before any partition manipulation
- Debian/Ubuntu distribution or manual installation
Warning: creating RAID on disks containing data erases them. Check
lsblkand labels.
Disk inventory
lsblk -o NAME,SIZE,TYPE,MODEL,SERIAL
cat /proc/mdstat
mdadm --detail --scan
Install mdadm if missing:
apt update && apt install -y mdadm
Create RAID 1 (mirror)
Example: /dev/sdb and /dev/sdc, partition type Linux RAID (fd for MBR, raid for GPT).
parted /dev/sdb --script mklabel gpt mkpart primary 1MiB 100% set 1 raid on
parted /dev/sdc --script mklabel gpt mkpart primary 1MiB 100% set 1 raid on
Create array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
Follow prompts (optional alert email). Format:
mkfs.ext4 /dev/md0
mkdir -p /mnt/raid
mount /dev/md0 /mnt/raid
Persistence: mdadm.conf and fstab
Capture configuration:
mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
update-initramfs -u
UUID for fstab:
blkid /dev/md0
Add to /etc/fstab:
UUID=xxxxxxxx /mnt/raid ext4 defaults,nofail 0 2
Create RAID 5 (overview)
Three disks minimum:
mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/sdd1 /dev/sde1 /dev/sdf1
Usable capacity ≈ (N-1) × smallest disk size.
Monitoring
Real-time state:
cat /proc/mdstat
mdadm --detail /dev/md0
watch -n 2 cat /proc/mdstat
Alert email: configure MAILADDR in /etc/mdadm/mdadm.conf and a local MTA.
Replace a failed disk
Mark disk failed (example sdb1):
mdadm /dev/md0 --fail /dev/sdb1
mdadm /dev/md0 --remove /dev/sdb1
After physical replacement, recreate identical partition, then:
mdadm /dev/md0 --add /dev/sdb1
Resync appears in /proc/mdstat (recovery).
Degraded at boot
mdadm --assemble --scan
mdadm --detail /dev/md0
Troubleshooting
| ----------- | ---------- |
|---|---|
| RAID stopped | mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1 |
| Inconsistent superblock | mdadm --examine /dev/sdb1 (compare members) |
| Force assemble (danger) | Last resort — HolyCloud support |
Need help?
For hardware RAID (LSI/HPE controller), specify the model in your ticket — procedure differs from mdadm.