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).
If you are booting from an ISO via iDRAC, see How to boot a server into a custom ISO image using iDRAC.
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
Check your server's boot mode before you begin. This determines whether you need the EFI System Partition (ESP) below. Press F2 during startup to open System Setup, then 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.
For each disk (/dev/sda and /dev/sdb), create the same partition layout:
- (UEFI only) A small ESP (e.g., 512 MB), formatted as FAT32, mounted at
/boot/efi. - A small partition for
/boot(e.g., 1 GB), set Format to leave unformatted. - A partition for the root filesystem (remaining space), 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/md0asext4, mount as/boot. - Format
/dev/md1asext4, 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.
- Find the ESP partition UUIDs:
sudo blkid - 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/ - 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' - Add the second disk's ESP to
/etc/fstab, using the UUID from step 1, and add thenofailoption 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 - 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/mdstatExample 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/md1Set up email alerts
Edit /etc/mdadm/mdadm.conf:
MAILADDR your@email.comThen restart the monitoring daemon:
sudo systemctl restart mdmonitorSimulating 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.
- Mark a disk as failed (for testing):
sudo mdadm --fail /dev/md1 /dev/sdb3
sudo mdadm --remove /dev/md1 /dev/sdb3- Add a replacement disk, re-add the partition (or, after replacing the physical disk, repartition it to match
/dev/sdabefore adding it back):
sudo mdadm --add /dev/md1 /dev/sdb3- The array will automatically rebuild. Monitor progress with:
watch cat /proc/mdstatIf the entire disk /dev/sdb failed rather than a single partition, repeat this procedure for /dev/md0 as well.