Course contentsShow
← Linux
Lesson 707 of 1,8197. Storage Management and Logical VolumesFree lesson

Persistent assembly of RAID arrays

Configure system persistence for arrays to ensure consistent assembly at boot time.

In this lesson, you will learn how to ensure your software RAID arrays are automatically and correctly reassembled by the Linux kernel every time your system boots.

Why Persistence Matters

When you create a RAID array using mdadm, the kernel might assemble it successfully during the current session. However, after a reboot, the system needs to know which physical drives belong to which array and in what order they should be activated. If the system doesn't know this, your array might remain inactive, or worse, get assigned a different device name (like /dev/md127 instead of /dev/md0), which can break your LVM configurations or mount points.

The mdadm.conf File

The primary tool for managing this is the configuration file located at /etc/mdadm/mdadm.conf. This file acts as a map for the mdadm daemon to scan your drives upon startup. To keep your configuration persistent, you must explicitly tell the system about your active arrays.

First, you can view the current configuration of your arrays by running:

sudo mdadm --detail --scan

This command generates the exact configuration line needed for your array. To make it persistent, append this output to your configuration file:

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

Updating the Initial RAM Filesystem (initramfs)

Because RAID arrays are often required before the root filesystem is even mounted, the kernel needs this configuration information early in the boot process. After modifying /etc/mdadm/mdadm.conf, you must update the initramfs (the initial environment the kernel loads). On most modern Linux distributions, you can do this by running:

sudo update-initramfs -u

By updating the initramfs, you bake the RAID configuration into the boot image. This ensures that the kernel identifies the component drives and assembles the array consistently, regardless of hardware device enumeration changes. Without this final step, your array might fail to assemble early enough in the boot sequence, leading to mount errors for any filesystems residing on the RAID volume.

Key Takeaway: Persistent RAID assembly requires both a correctly formatted /etc/mdadm/mdadm.conf file and a refreshed initramfs to ensure the kernel detects and mounts your arrays reliably at boot.