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.

Note: On Linux, software RAID is managed with mdadm. This guide uses mdadm to monitor arrays and recover from disk failures.

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

  1. Check your server's boot mode before you begin:
    • Press F2 during startup to open System Setup.
    • Go to Boot Settings and check whether Boot Mode is set to UEFI or BIOS. Include the ESP only if it is set to UEFI; skip it for BIOS.
  2. Create the same partition layout on each disk (/dev/sda and /dev/sdb):
    • UEFI only: Create a small ESP (e.g., 512 MB), format it as FAT32, and mounted it at /boot/efi. Skip this partition if Boot Mode is set to BIOS.
    • Create a partition for /boot (e.g., 1 GB) and set Format to leave unformatted.
    • Use the remaining space for the root filesystem partition and set Format to leave unformatted.

You assign the filesystem to the /boot and root partitions later, after combining them into a RAID array. The ESP can not be part of a RAID array, mdadm does not mirror it.

Step 4: Create RAID arrays

Select Create software RAID (md) and configure:

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

If you skipped the ESP (legacy BIOS boot), use /dev/sda1//dev/sdb1 for the boot partitions and /dev/sda2//dev/sdb2 for the root partitions instead.

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. In UEFI mode, it installs the bootloader only to the first disk's ESP. See the next section to make the second disk bootable too.

Enable UEFI boot from the second disk

Skip this section if the server uses legacy BIOS boot.

The Ubuntu installer registers the bootloader with only one disk's ESP (/dev/sda1 in this example). If that disk fails, the server can not boot via UEFI from the second disk unless you prepare it manually.

  1. Find the ESP partition UUIDs:
    sudo blkid
  2. Create a mount point for the second disk's ESP, mount it, and copy the bootloader files to it:
    sudo mkdir /boot/efi2
    sudo mount /dev/sdb1 /boot/efi2
    sudo cp -av /boot/efi/. /boot/efi2/
  3. Register a UEFI boot entry for the second disk:
    sudo efibootmgr -c -g -d /dev/sdb -p 1 -L "ubuntu #2" -l '\EFI\ubuntu\shimx64.efi'
  4. Add the second disk's ESP to /etc/fstab, using the UUID from step 1, and add the nofail option to both ESP entries so the system does not drop into recovery mode if one disk fails to mount:
    UUID=<esp1-uuid>  /boot/efi   vfat  umask=0077,nofail  0  1
    UUID=<esp2-uuid>  /boot/efi2  vfat  umask=0077,nofail  0  1
  5. Check the boot order, then reboot once using the second disk's entry to confirm it works:
    sudo efibootmgr -v
    sudo efibootmgr -n <bootnum>
    sudo reboot

Verifying the RAID array after boot

Check the RAID status:

cat /proc/mdstat

Example healthy output:

md1 : active raid1 sdb3[1] sda3[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

This section shows how the RAID array responds to a failure, for testing purposes.

If a disk has actually failed on a server, contact Servers.com support.

  1. Mark a disk as failed (for testing):
sudo mdadm --fail /dev/md1 /dev/sdb3
sudo mdadm --remove /dev/md1 /dev/sdb3
  1. Add a replacement disk, re-add the partition (or, after replacing the physical disk, repartition it to match /dev/sda before adding it back):
sudo mdadm --add /dev/md1 /dev/sdb3
  1. The array will automatically rebuild. Monitor progress with:
watch cat /proc/mdstat

If the entire disk /dev/sdb failed rather than a single partition, repeat this procedure for /dev/md0 as well.

On this page