This episode teaches you how to create your first array with mdadm using --create, understand metadata versions from 0.90 to 1.2, write the mdadm.conf configuration, and ensure the array assembles automatically at boot.

After understanding the concepts and choosing software RAID in episode 3, it's now time to take action. Episode 4 teaches two of the most fundamental operations with mdadm: creating an array with --create and reassembling an array with --assemble. These two abilities are the foundation of every RAID operation that follows.
You'll also get acquainted with metadata — the configuration data written to the disks that tells mdadm about the array's level, members, and status. Understanding metadata is the key to keeping your array portable across machines and booting automatically. Let's get started.
The --create command builds a new array from a set of devices. The most common example for a mirror:
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdcLook at the command components above: --create /dev/md0 names the array, --level=1 specifies the RAID level, --raid-devices=2 declares the number of members, and the last two devices are the member disks. When run, mdadm asks whether you're sure you want to create a new array on devices that already have data — answer y only if you're certain.
After the command runs, the kernel starts mirror synchronization. Check its status:
cat /proc/mdstatThe /proc/mdstat output shows a line like md0 : active raid1 sdb[0] sdc[1] with resync and a progress percentage. Let the synchronization finish before using the array; the duration depends on disk size.
Metadata is a small area on the disk that stores array information. mdadm supports four versions:
For booting from an array, version 1.0 (metadata at the end) is the most GRUB-compatible choice, and we'll discuss it in episode 11.
sudo mdadm --examine /dev/sdbThe output of mdadm --examine /dev/sdb shows the metadata version, array UUID, and level. Use this whenever you're unsure about a disk's origin.
When creating a parity array, you can also specify the chunk size with --chunk=64 (in kilobytes). A chunk is the size of the data piece distributed to each disk per stripe. The default 512K suits large workloads; chunks of 64K to 256K are better for random workloads. We'll dig deeper into chunk tuning in episode 18.
For naming, Linux assigns /dev/md0 through /dev/md127 in sequence. For stability, make sure the array is stored in mdadm.conf so the number doesn't change across reboots.
When disks are plugged into a machine, mdadm can "assemble" the array from the metadata scattered across the disks:
sudo mdadm --assemble --scan
sudo mdadm --detail /dev/md0--assemble --scan reads the configuration from mdadm.conf and the metadata, then activates every array it finds. The incremental mode (--incremental) is used by udev every time a disk appears, so an array can partially assemble during boot before all disks are available.
To make sure the array is always recognized, save its configuration:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
sudo update-initramfs -uThe file /etc/mdadm.conf (in some distros /etc/mdadm/mdadm.conf) contains a line like ARRAY /dev/md0 UUID=... that is looked up during --assemble --scan. Don't forget to run update-initramfs -u so the initramfs includes the configuration and drivers needed at boot.
Info
Before removing an array, always keep a copy of mdadm --detail and --examine. This information is your roadmap for recovering the array if the metadata misbehaves later on.
Once the array is active, the final step is creating a filesystem and mounting it:
sudo mkfs.ext4 /dev/md0
sudo mkdir -p /mnt/raid
sudo mount /dev/md0 /mnt/raidThe mkfs.ext4 /dev/md0 command creates a filesystem on top of the MD device, and mount attaches it to /mnt/raid. For a persistent mount, add an entry to /etc/fstab using the filesystem UUID so nothing gets lost if the device name changes.
sudo blkid /dev/md0The output of blkid /dev/md0 shows the UUID of the newly created filesystem. Use that value in the /etc/fstab line, for example UUID=... /mnt/raid ext4 defaults 0 2.
Episode 4 gave you the most fundamental ability: creating a RAID 1 array with mdadm --create, choosing the right metadata, assembling the array with --assemble, saving the configuration in mdadm.conf, and creating a filesystem on top. These skills are the backbone of all subsequent episodes.
Key takeaways:
--create builds an array; make sure the member disks are correct before confirming.mdadm --examine reads the metadata from a disk.--assemble --scan and mdadm.conf keep the array active automatically at boot.update-initramfs after changing mdadm.conf.blkid for a stable fstab entry.In the next episode, episode 5, we'll discuss mdadm detail, status & monitoring — reading --detail and /proc/mdstat, interpreting array states such as clean, active, and degraded, and running --monitor and mdmonitor for notifications. You'll learn to read an array's condition like a professional.