Exercise: Introduction to Software RAID

Creating a Mirrored Array with mdadm

A hands-on exercise on how to create a RAID 1 (mirror) software array using multiple virtual disks and the mdadm utility.
Author

Chuck Nelson

Published

October 22, 2025

1 Purpose

This exercise introduces you to the powerful concept of RAID (Redundant Array of Independent Disks). You will use multiple virtual disks to create a fault-tolerant RAID 1 array, also known as a “mirror.” This is a foundational skill for anyone responsible for systems where data redundancy and uptime are critical. You will use the standard Linux tool for software RAID, mdadm.

2 What You’ll Accomplish

By the end of this exercise, you will be able to:

  • Create multiple virtual disk images to serve as members of a RAID array.
  • Use mdadm to create a RAID 1 array from two block devices.
  • Check the status and health of a software RAID array.
  • Format and mount the RAID array as a single logical volume.
  • Stop and disassemble a software RAID array.

This exercise maps to the following program and course learning outcomes:

  • Program Learning Outcomes (PLOs):
    • 6. Maintain environment: Creating a redundant storage array is a primary method for maintaining a high-availability data environment.
  • Course Learning Outcomes (CLOs):
    • 4. Configure hardware and basic network components: Building a software RAID array is an advanced and powerful system configuration task.

This exercise develops the following skills, which align with the O*NET SOC Code 15-1232.00 for Computer User Support Specialists.

Learning Objective O*NET KSAs Technologies Used
Create a software RAID 1 array. Knowledge: Computers & Electronics
Skills: Installation, Systems Analysis
mdadm, RAID
Check the status of a RAID array. Knowledge: Computers & Electronics
Skills: Troubleshooting, Monitoring
mdadm

3 Prerequisites

This exercise requires a running Fedora 42 virtual machine with internet access and a user account with sudo privileges. We will be using the raw image and losetup method consistent with the previous exercises.

4 Step-by-Step Guide

Open a terminal window in your Fedora VM to begin.

4.1 Step 1: Install mdadm

mdadm (multiple disk and device administration) is the standard tool for managing software RAID in Linux.

  1. Run the following command to install the package:

    sudo dnf install -y qemu-img mdadm

4.2 Step 2: Create and Attach Two Virtual Disks

For a RAID 1 mirror, you need at least two identical drives. You will create two new, smaller virtual disks for this purpose using the pre-allocated raw format.

  1. Create the first 500MB raw disk image:

    
    qemu-img create -f raw -o preallocation=falloc disk_a.img 500M
  2. Create the second 500MB raw disk image:

    qemu-img create -f raw -o preallocation=falloc disk_b.img 500M
  3. Attach both disks as loop devices:

    sudo losetup -fP disk_a.img
    sudo losetup -fP disk_b.img
  4. Verify their names with lsblk or losetup -a. You should see two new loop devices (e.g., loop0 and loop1).

In your student notebook, write down the names of the two new loop devices.

4.3 Step 3: Create the RAID 1 Array

Now you will use mdadm to combine the two loop devices into a single mirrored array, which will appear as a new device called /dev/md0.

  1. Run the mdadm --create command. The arguments specify the name of the new array, the RAID level (--level=1), and the number and names of the devices to include.

    
    # Replace /dev/loop0 and /dev/loop1 if your device names are different
    
    sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/loop0 /dev/loop1

    You will be asked to confirm. Type y and press Enter.

  2. mdadm will begin building the array. You can watch the progress with the following command:

    watch cat /proc/mdstat

    This will update every two seconds. Wait for the [UU] status, which means both drives are up and synced. Press Ctrl+C to exit watch.

4.4 Step 4: Examine and Format the Array

  1. Use mdadm --detail to see a detailed report of your new array’s status.

    sudo mdadm --detail /dev/md0

    Notice that the “State” is active and you have two active devices.

  2. Now, you can treat /dev/md0 as a single block device. Format it with an ext4 filesystem:

    sudo mkfs.ext4 /dev/md0

4.5 Step 5: Mount and Use the Array

  1. Create a mount point:

    sudo mkdir /mnt/my_raid_mirror
  2. Mount the array:

    sudo mount /dev/md0 /mnt/my_raid_mirror
  3. Check the result with df -h. You will see /dev/md0 mounted, and its total size will be approximately 500MB, not 1GB. This is because it’s a mirror—you get the capacity of only one drive.

Take a screenshot of the mdadm --detail output and add it to your notebook.

4.6 Step 6: Clean Up

When you are finished, it is important to stop the array and detach the loop devices.

  1. Unmount the filesystem:

    sudo umount /mnt/my_raid_mirror
  2. Stop the RAID array. This deactivates /dev/md0.

    sudo mdadm --stop /dev/md0
  3. Detach the two loop devices. Use the names you recorded earlier.

    # Replace with your actual device names
    sudo losetup -d /dev/loop0
    sudo losetup -d /dev/loop1

5 Reflect and Review

ImportantReflection: 3-2-1

Now that you have completed this exercise, reflect on your experience in your Microsoft Teams Student Notebook:

  • 3 mdadm commands or flags you used.
  • 2 reasons you might choose to use RAID 1.
  • 1 question you still have about how software RAID works.
TipCheck on Learning

Answer these questions in your notebook to solidify your understanding:

  1. What does the --level=1 flag specify in the mdadm --create command?
  2. You created a RAID 1 array with two 500MB disks. Why was the final usable capacity only 500MB?
  3. In the output of cat /proc/mdstat, what does a status of [UU] indicate? What might [U_] indicate?
  4. What command do you use to stop a RAID array after you have unmounted it?
Back to top