Build a Debian 12 RAID 1 Mirror with mdadm

To create a Debian 12 software RAID 1 mirror from two blank disks, install mdadm, verify the exact device names, create /dev/md0, and build a filesystem on the array device. In this example, /dev/sdb and /dev/sdc are dedicated data disks; replace them with your verified device paths. Do not run the create or format commands on disks that contain data you need.

This procedure is for a new data volume, not a root or boot mirror. RAID 1 keeps mirrored copies and can continue after one member fails, but it does not protect against deletion, filesystem damage, theft, or a second disk failure. Keep a separate backup. Debian’s Bookworm mdadm manual documents the create and metadata options used below.

Before you create the array: verify the disks

RAID 1 capacity is limited by the smaller member. Use disks at least as large as the data volume you need, preferably matching drives connected through independent ports. You can use whole disks as shown here or create same-sized partitions on each disk and mirror those partitions. The choice depends on your partitioning and future storage plan; do not mix a whole-disk member with a partition member accidentally.

First list devices and filesystems:

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
sudo wipefs -n /dev/sdb /dev/sdc

lsblk shows sizes, partitions, filesystems, and mount points. wipefs -n only reports signatures; it does not erase them. Confirm by model, serial, capacity, and mount point that both targets are the intended, unmounted disks. Device letters can change after hardware or boot changes, so for servers, identify drives with stable /dev/disk/by-id/ paths and use those paths consistently.

Terminal view of lsblk listing two unmounted, unformatted disks named sdb and sdc
The terminal view shows the disk inventory check: confirm both member disks and their mount points before creating the mirror.

Common misconception: RAID 1 does not combine two disk capacities into one larger volume. It mirrors writes, so the usable space is approximately that of the smaller disk. Check the reported sizes now and plan for that mirrored capacity.

Create and monitor the RAID 1 device

Install Debian’s RAID management utility, then create a two-device mirror:

sudo apt update
sudo apt install mdadm
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

Answer the confirmation prompt only after checking the member paths again. --level=1 selects mirroring, while --raid-devices=2 sets the number of active members. Debian Bookworm’s mdadm uses version 1.2 metadata by default for new arrays; specify a different metadata format only when a verified boot or compatibility requirement calls for it. The command writes RAID metadata to the selected devices. Treat them as disposable and never assume existing filesystems will remain usable.

Terminal displaying the mdadm command to create a two-disk RAID 1 array
The command starts /dev/md0 as a two-member RAID 1 array; the disk paths must match the devices you verified.

Creation starts synchronization, which can take a long time depending on disk size and activity. It is not proof that both copies are fully synchronized yet. Check progress with:

cat /proc/mdstat
sudo mdadm --detail /dev/md0

Look for raid1, both expected members, and [UU] when the array is fully active with both devices present. While a resync is running, /proc/mdstat reports progress; avoid heavy writes until it finishes if practical. Exact speed and duration depend on the drives, controller, and workload, so do not infer a completion time from another machine’s output.

Terminal view of proc mdstat showing a RAID 1 resync at 42 percent
The sample status display shows an in-progress resync; wait for synchronization to finish and confirm both member indicators are present.

Common misconception: the array device is not ready to format just because the create command returned. Check /proc/mdstat and mdadm --detail first, and confirm the member list matches your two disks.

Format, mount, and make assembly persistent

Once /dev/md0 is active and its members are correct, create a filesystem on the array device—not on each member disk—then mount it:

sudo mkfs.ext4 /dev/md0
sudo mkdir -p /srv/mirror
sudo mount /dev/md0 /srv/mirror
findmnt /srv/mirror

mkfs.ext4 erases data on its target. Formatting /dev/md0 creates one filesystem across the logical mirror, while formatting /dev/sdb or /dev/sdc separately would bypass the array. Confirm findmnt shows /dev/md0 mounted at /srv/mirror before writing files.

Terminal showing ext4 format and mount commands for the logical device /dev/md0
Run the filesystem and mount commands against /dev/md0, the assembled array device, rather than either physical member.

To help Debian reassemble the array by its identity at boot, inspect the generated entry:

sudo mdadm --detail --scan

Add the matching ARRAY line from the output to /etc/mdadm/mdadm.conf without replacing the rest of the file, then rebuild initramfs:

sudo nano /etc/mdadm/mdadm.conf
sudo update-initramfs -u -k all

Debian’s Handbook guidance for mdadm also recommends updating initramfs after changing this configuration. For automatic mounting, get the filesystem UUID and add a corresponding entry to /etc/fstab:

sudo blkid /dev/md0
# Example format; replace the UUID with the value from blkid:
UUID=your-filesystem-uuid /srv/mirror ext4 defaults,nofail 0 2

Use the actual UUID, not the example placeholder. Then validate the file and mount configuration:

sudo findmnt --verify
sudo mount -a
findmnt /srv/mirror

Verify the result and understand its limits

Confirm mdadm --detail /dev/md0 reports RAID level 1, both expected members, and a clean state after synchronization. Confirm /proc/mdstat shows both devices, then check that findmnt /srv/mirror reports the ext4 filesystem mounted from the array. After a planned reboot, repeat the array and mount checks before storing important data.

RAID 1 can keep the volume available after one member fails, but redundancy is not a backup and does not verify that every file is recoverable. Keep versioned backups on separate storage, monitor array status, and replace a failed member using the exact device and recovery steps documented by mdadm’s Bookworm manual. This guide does not cover converting an existing Debian root disk into RAID; that needs a migration and bootloader plan specific to the machine.

Leave a Comment

Build a Debian 12 RAID 1 Mirror with mdadm

Build a Debian 12 RAID 1 Mirror with mdadm

Create and verify a two-disk Debian 12 RAID 1 data array, format it safely, and configure it to assemble and mount after reboot.

Encrypt Debian 12 Swap with a Fresh Key at Every Boot

Encrypt Debian 12 Swap with a Fresh Key at Every Boot

Set up random-key encryption for an existing Debian 12 swap partition, verify the active dm-crypt mapping, and understand the hibernation trade-off.

How to Restrict SSH Users to Specific Directories on Ubuntu 24.04 (SFTP Chroot Guide)

How to Restrict SSH Users to Specific Directories on Ubuntu 24.04 (SFTP Chroot Guide)

Restrict Ubuntu 24.04 SSH accounts to designated SFTP folders with chroot, proper permissions, Match rules, and safe tests—without granting shell access.

Release Ubuntu’s APT Lock Safely and Finish the Update

Release Ubuntu’s APT Lock Safely and Finish the Update

Find which process owns Ubuntu’s dpkg frontend lock, let package work finish, and repair interrupted installations without deleting lock files.

How to Set Up Automated Btrfs Snapshots on Ubuntu Desktop

How to Set Up Automated Btrfs Snapshots on Ubuntu Desktop

Set up scheduled Btrfs system snapshots on Ubuntu Desktop with Timeshift, verify the Ubuntu subvolume layout, choose retention, and understand what snapshots cannot protect.

How to Migrate Debian 12 to Testing Without Breaking Dependencies

How to Migrate Debian 12 to Testing Without Breaking Dependencies

Plan a safer Debian 12 to Testing migration: upgrade through Stable, back up, clean APT sources, simulate dependency changes, and verify what changed.

Ubuntu Server Booting into Emergency Mode: A Step-by-Step Rescue Guide

Ubuntu Server Booting into Emergency Mode: A Step-by-Step Rescue Guide

Diagnose Ubuntu Server emergency mode safely. Read boot logs, check root and fstab mounts, repair a failed unit, handle filesystem errors, and verify a clean reboot.

How to Configure a WireGuard Point-to-Site VPN on Debian 12

How to Configure a WireGuard Point-to-Site VPN on Debian 12

Set up a Debian 12 WireGuard VPN server for one remote client. Configure keys, IPv4 forwarding, nftables NAT, firewall access, and connection checks.

Step-by-Step Debian 12 Hardening Guide for CIS Compliance

Step-by-Step Debian 12 Hardening Guide for CIS Compliance

Harden a Debian 12 workstation with a careful CIS Benchmark workflow: select the right profile, patch safely, review services and access, configure nftables, and document evidence.

Debian 12 on a Low-RAM VPS: How to Reduce MySQL OOM Crashes

Debian 12 on a Low-RAM VPS: How to Reduce MySQL OOM Crashes

Diagnose MySQL OOM kills on Debian 12, check VPS memory limits, configure swap, and tune database memory and concurrency without promising a universal fix.