How to install Ubuntu with software RAID 1

RAID ("Redundant Array of Independent Disks") is a method of using multiple disks for different combinations to increase the reliability of data storage and/or improve performance of read/write operations, depending on the RAID level.

RAID-1 (mirroring) writes identical data to two or more disks. If one disk fails, the other contains a full copy of all data, providing high availability.

Prerequisites

  • A server with at least two disks of equal or similar size.
  • Ubuntu Server installation media (ISO or network boot).

Setting up RAID-1 during Ubuntu installation

Step 1: Boot the installer

Boot from the Ubuntu Server installation media. Proceed through the language, keyboard, and network setup screens until you reach the Storage configuration step.

Step 2: Switch to manual partitioning

Select Custom storage layout (or Manual in older installers) instead of the automatic option.

Step 3: Create partitions on both disks

For each disk (/dev/sda and /dev/sdb), create the same partition layout:

  1. A small partition for /boot (e.g., 1 GB), type Linux filesystem.
  2. A partition for the root filesystem (remaining space), type Linux filesystem.

Mark each partition as a software RAID member rather than assigning a filesystem directly.

Step 4: Create RAID devices

Select Create software RAID (md) and configure:

  • RAID-1 for the boot partitions (/dev/sda1 + /dev/sdb1) → /dev/md0
  • RAID-1 for the root partitions (/dev/sda2 + /dev/sdb2) → /dev/md1

Step 5: Format and assign mount points

  • Format /dev/md0 as ext4, mount as /boot.
  • Format /dev/md1 as ext4, mount as / (root).

Step 6: Complete installation

Proceed with the rest of the installation. The installer will configure mdadm and update initramfs automatically.

Verifying the RAID array after boot

Check the RAID status:

cat /proc/mdstat

Example healthy output:

md1 : active raid1 sdb2[1] sda2[0]
      976760832 blocks super 1.2 [2/2] [UU]

Two U characters indicate both disks are active and in sync.

Monitoring with mdadm

sudo mdadm --detail /dev/md1

Set up email alerts

Edit /etc/mdadm/mdadm.conf:

MAILADDR your@email.com

Then restart the monitoring daemon:

sudo systemctl restart mdmonitor

Simulating and recovering from a disk failure

Mark a disk as failed (for testing):

sudo mdadm --fail /dev/md1 /dev/sdb2
sudo mdadm --remove /dev/md1 /dev/sdb2

Add a replacement disk:

sudo mdadm --add /dev/md1 /dev/sdb2

The array will automatically rebuild. Monitor progress with:

watch cat /proc/mdstat

On this page