How to Build RAID 1 on Ubuntu: Software RAID with mdadm Explained

1. Introduction

Why Build RAID 1 on Ubuntu?

Ubuntu is a Linux distribution widely used from individual users to enterprise environments. Due to its high reliability and flexibility, it is commonly adopted for server use. By building RAID 1 (mirroring) in an Ubuntu environment, you can ensure data redundancy and minimize the risk of data loss caused by disk failures.

RAID 1 works by writing identical data to two or more disks in real time. Even if one disk fails, the system can continue operating using the remaining disk. For Ubuntu systems handling critical files or services, RAID 1 is an effective protection strategy.

Differences Between Software RAID and Hardware RAID

There are two main approaches to building RAID. One is hardware RAID, which uses a dedicated RAID controller or motherboard RAID features. The other is software RAID, which is configured using operating system software (primarily mdadm on Linux).

On Ubuntu, software RAID is the most common choice due to its cost efficiency and flexibility. This article focuses on building RAID 1 on Ubuntu, covering installation-time configuration, operational management, and failure recovery.

What You Will Learn in This Article

By reading this guide, you will gain the following knowledge and skills:

  • RAID 1 fundamentals and how it operates on Ubuntu
  • Step-by-step instructions for building RAID 1 using software RAID (mdadm)
  • RAID 1 rebuilding, status checks, and troubleshooting
  • Differences and precautions between Ubuntu Server and Desktop
  • Practical FAQ knowledge including GRUB and fstab configuration

Once configured, RAID does not require frequent intervention, but understanding the initial setup is critical. This article provides clear and practical explanations suitable even for beginners. Please read through to the end.

2. RAID 1 Fundamentals

RAID Levels and Characteristics of RAID 1

RAID (Redundant Array of Independent Disks) is a technology that combines multiple hard drives to improve data reliability and performance. RAID has multiple levels, each with different characteristics.

Common RAID levels include:

  • RAID 0: Improves performance through striping, but offers no redundancy
  • RAID 1: Provides redundancy through mirroring (the focus of this article)
  • RAID 5: Uses parity across three or more disks to provide redundancy
  • RAID 6: An enhanced version of RAID 5 with dual parity for higher fault tolerance
  • RAID 10 (1+0): A combination of RAID 1 and RAID 0

Among these, RAID 1 uses a mirroring approach that writes identical data to two disks. If one disk fails, data remains accessible from the other, providing excellent availability.

How Mirroring Works (Conceptual Example)

The mechanism of RAID 1 is very simple. For example, suppose you have Disk A and Disk B:

[Write Operation]
User saves File A → Data is written simultaneously to Disk A and Disk B

[Read Operation]
Data can be read from either disk, allowing performance optimization

Because data is always duplicated, RAID 1 offers strong protection against physical disk failures.

Software RAID vs Hardware RAID

There are two main methods for building RAID:

  • Software RAID (mdadm, etc.)
    This is the most commonly used method on Ubuntu. RAID is managed at the OS level, offering flexibility and cost advantages. It provides the highest level of control and is widely used in general server environments.
  • Hardware RAID (RAID cards or BIOS-based solutions)
    RAID is handled by a dedicated controller, reducing CPU load. The OS recognizes the array as a single disk. However, recovery becomes difficult if the controller itself fails.

What Is Fake RAID (BIOS RAID)?

Some motherboards provide RAID functionality at the BIOS level, often referred to as “Fake RAID.”

Although it appears to be hardware RAID, it is actually driver-controlled and structurally closer to software RAID. While Ubuntu offers limited support, mdadm-based software RAID is generally easier to manage and recover, so Fake RAID is usually not recommended.

3. Building RAID 1 with Software RAID (mdadm)

3.1 Preparation and Requirements

To build RAID 1, you need at least two physical disks (or unused partitions). Disks already used as system disks are not suitable, so prepare dedicated storage.

First, identify the target disks:

lsblk

Or check more detailed information:

sudo fdisk -l

Assume the disks are /dev/sdb and /dev/sdc.

Before proceeding, make sure the target disks contain no important data. All data will be erased during RAID creation.

3.2 Installing mdadm

mdadm is included in the Ubuntu default repositories and can be installed easily:

sudo apt update
sudo apt install mdadm

You may be prompted for mail notification settings during installation. These can be adjusted later, so the default settings are fine initially.

3.3 Creating a RAID 1 Array

Once the disks are confirmed, create the RAID 1 array with the following command:

sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

Command explanation:

  • /dev/md0: Name of the new RAID device
  • --level=1: Specifies RAID level 1 (mirroring)
  • --raid-devices=2: Number of devices in the array
  • /dev/sdb /dev/sdc: The actual disks used

After creation, check the status:

cat /proc/mdstat

If you see synchronization information along with /dev/md0, the RAID 1 array has been successfully created.

3.4 Persistent Configuration (mdadm.conf and fstab)

To ensure the RAID array is recognized after reboot, persistent configuration is required.

First, save the current RAID configuration:

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

Next, create a filesystem on the RAID array (example: ext4):

sudo mkfs.ext4 /dev/md0

Create a mount point and mount it:

sudo mkdir -p /mnt/raid1
sudo mount /dev/md0 /mnt/raid1

After verifying operation, add it to /etc/fstab using the UUID:

sudo blkid /dev/md0

Add an entry like the following:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/raid1 ext4 defaults 0 0

This ensures the RAID 1 array is automatically mounted after reboot.

4. Configuring RAID 1 During Ubuntu Installation

4.1 Using the Ubuntu Server Installer

The Ubuntu Server installer supports advanced storage configurations such as RAID and LVM.

Step 1: Boot from Installation Media
Create a bootable USB from the Ubuntu Server ISO and start the target machine.

Step 2: Complete Basic Setup
Configure language, keyboard, and networking.

Step 3: Proceed to Storage Configuration
Select Custom Storage Layout instead of Guided.

Step 4: Configure RAID

  1. Select two empty disks
  2. Create partitions (e.g., /boot, swap, /)
  3. Select “Create Software RAID”
  4. Choose RAID 1 and assign devices
  5. Assign filesystems and mount points

Step 5: Install GRUB
It is recommended to install GRUB on both disks so the system can boot even if one disk fails.

4.2 Using RAID with Ubuntu Desktop

Ubuntu Desktop does not include RAID configuration in its installer. To use RAID 1, consider the following methods:

Method 1: Manually Build RAID in Live Environment → Install Desktop

  1. Boot from Live USB
  2. Build RAID 1 using mdadm
  3. Install Ubuntu Desktop on the RAID device (e.g., /dev/md0)
  4. Adjust grub and fstab settings

This method requires more effort but offers high flexibility for GUI-based RAID usage.

Method 2: Install Server with RAID → Add GUI Later

sudo apt update
sudo apt install ubuntu-desktop

This approach is stable and recommended when you want to add a GUI to a RAID-configured system.

Choosing Between Desktop and Server

CriteriaServerDesktop
Ease of RAID Setup◎ Built-in installer support△ Manual setup required
GUI× (CLI-focused)◎ Included by default
Beginner Friendly△ Requires experience◎ Easy installation
Flexibility◎ Server-oriented○ Customizable

If RAID is central to your system, starting with Ubuntu Server is the smoothest approach.

5. RAID 1 Operation and Troubleshooting

5.1 Monitoring RAID Status

Regular monitoring is essential for early failure detection:

cat /proc/mdstat

[UU] indicates normal operation, while [_U] indicates one disk is missing.

For more details:

sudo mdadm --detail /dev/md0

5.2 Handling Disk Failures and Rebuilding

RAID 1 allows continued operation even if one disk fails.

Step 1: Identify the failed disk
Check for “Removed” or “Faulty” status.

Step 2: Remove the failed disk

sudo mdadm /dev/md0 --remove /dev/sdX

Step 3: Prepare the new disk

sudo fdisk /dev/sdX

Step 4: Add the disk and start rebuild

sudo mdadm /dev/md0 --add /dev/sdX

5.3 Installing GRUB for Redundancy

Install GRUB on both disks to ensure boot redundancy:

sudo grub-install /dev/sdX
sudo update-grub

6. Using Hardware RAID

6.1 What Is Hardware RAID?

Hardware RAID uses a dedicated controller to manage RAID operations, offering high performance and reduced CPU load.

6.2 Pros and Cons of Hardware RAID on Ubuntu

Advantages:

  • Low CPU usage
  • OS-independent configuration
  • Fast recovery and hot-swap support

Disadvantages:

  • Recovery is difficult if the RAID card fails
  • Less flexibility
  • Higher cost

6.3 Checking Hardware RAID Status

Hardware RAID arrays appear as single block devices. Status must be checked using vendor utilities.

7. Frequently Asked Questions (FAQ)

Q1. Is RAID 1 a replacement for backups?

No. RAID 1 protects against disk failure, not data loss from deletion or corruption.

Q2. What happens if one disk fails?

The system continues operating using the remaining disk.

Q3. Can RAID 1 be used on Ubuntu Desktop?

Yes, but setup must be done manually.

Q4. How do I check RAID status?

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

Q5. Do I need to reinstall GRUB after disk replacement?

Yes, GRUB should be installed on the replacement disk.

8. Conclusion

RAID 1 Is About Redundancy

RAID 1 provides real-time data duplication, allowing systems to continue running after disk failures.

RAID Options on Ubuntu

mdadm-based software RAID is the most practical choice for most Ubuntu users.

Maintenance Determines Reliability

Regular monitoring, correct GRUB setup, and proper backups are essential for long-term stability.

With Ubuntu and mdadm, RAID 1 can be built simply using command-line tools. Use this guide to create a robust and reliable Linux environment.