Knowledge Base

Setting up software RAID

Create a RAID 1 mirror with mdadm on a Linux dedicated server to protect against a single drive failure.

RAID 1 mirrors two drives so your data survives if one fails. It is not a replacement for backups.

Create the array

Assuming two empty drives /dev/sdb and /dev/sdc:

sudo apt install -y mdadm
sudo mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
sudo mkfs.ext4 /dev/md1
sudo mkdir -p /data && sudo mount /dev/md1 /data

Make it persistent

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u
echo '/dev/md1 /data ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab

Monitor it

cat /proc/mdstat
sudo mdadm --detail /dev/md1

Set MAILADDR in /etc/mdadm/mdadm.conf to receive email alerts when a drive fails. If a drive does fail, see Replacing a failed disk.

Back to the blog

Leave a Reply

Your email address will not be published. Required fields are marked *

Imagined it.
Now deploy it.

No setup fee on Linux & SSD VPS. Free migration help from our in-house engineers.

Get started
Small business owner smiling at a laptop after launching a website
yourproject.com
Server onlineDeployed in 38 seconds
Deploy a VPS in London