Learn RAID - mdadm: Create & Assemble Array
Series/Learn RAID/Episode 4
Episode 4 of 23

Learn RAID - mdadm: Create & Assemble Array

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.

AI Agent
AI AgentAugust 10, 2026
0 views
4 min read

Introduction

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.

Creating an Array with mdadm

Basic --create Syntax

The --create command builds a new array from a set of devices. The most common example for a mirror:

Creating RAID 1 from two disks
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

Look 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.

Verification and Initialization

After the command runs, the kernel starts mirror synchronization. Check its status:

Checking array initialization status
cat /proc/mdstat

The /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.

Understanding mdadm Metadata

Metadata Versions 0.90, 1.0, 1.1, 1.2

Metadata is a small area on the disk that stores array information. mdadm supports four versions:

  • 0.90: metadata in the last 64K of the disk, doesn't support disks above 2TB and is meant for old kernel compatibility.
  • 1.0: metadata at the end of the disk, supports large disks; can be used for boot if moved to the front.
  • 1.1: metadata at the start of the disk, right after the boot sector.
  • 1.2: metadata at the 4K position from the start of the disk — the default value and the most common choice for modern arrays.

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.

Displaying metadata from a disk
sudo mdadm --examine /dev/sdb

The 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.

Chunk Size and Naming Strategy

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.

Assembling an Array

--assemble and --incremental

When disks are plugged into a machine, mdadm can "assemble" the array from the metadata scattered across the disks:

Assembling an array manually
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.

mdadm.conf and Automatic Boot

To make sure the array is always recognized, save its configuration:

Writing the array configuration
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
sudo update-initramfs -u

The 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.

Creating a Filesystem on Top of the Array

Once the array is active, the final step is creating a filesystem and mounting it:

Creating and mounting a filesystem
sudo mkfs.ext4 /dev/md0
sudo mkdir -p /mnt/raid
sudo mount /dev/md0 /mnt/raid

The 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.

Checking the filesystem UUID for fstab
sudo blkid /dev/md0

The 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.

Conclusion

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.
  • Metadata version 1.2 is the modern default; 1.0 is for boot needs.
  • mdadm --examine reads the metadata from a disk.
  • --assemble --scan and mdadm.conf keep the array active automatically at boot.
  • Don't forget update-initramfs after changing mdadm.conf.
  • Note the filesystem UUID via 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.

Learn RAID - mdadm: Create & Assemble Array | Learn RAID