Fundamentals 11 min read

Mastering RAID: From Basics to Linux Software RAID 5 Setup

This article explains the fundamentals of RAID, compares common RAID levels, describes hardware RAID components, and provides a step‑by‑step guide for configuring a Linux software RAID 5 array with mdadm, including commands, monitoring, and recovery procedures.

Open Source Linux
Open Source Linux
Open Source Linux
Mastering RAID: From Basics to Linux Software RAID 5 Setup

Common RAID Types

RAID (Redundant Arrays of Inexpensive Disks) combines multiple small disks into a larger logical device that offers both increased capacity and data protection. The most frequently used RAID levels are described below.

RAID 0 – Striping (Best Performance)

Data is split into stripes and read/written in parallel across multiple disks, giving high throughput but no redundancy.

If any disk fails, all data is lost.

Not suitable for environments requiring high data safety.

RAID 1 – Mirroring (Full Backup)

Data is duplicated on a pair of disks, providing redundancy.

Read performance can improve because data can be read from either disk.

Highest cost per usable gigabyte but offers excellent reliability; the system can switch to the mirror automatically when a disk fails.

RAID 5 – Balanced Performance and Redundancy

Uses N (≥3) disks; data is striped across N‑1 disks with one parity block, giving N‑1/N usable capacity.

High read performance; write performance is lower due to parity calculations.

Can tolerate a single disk failure without data loss.

RAID 6 – Stronger Redundancy

Requires N (≥4) disks; stores two independent parity blocks, allowing up to two simultaneous disk failures.

Write performance is lower than RAID 5 because of the extra parity.

RAID 1+0 (RAID 10) – Mirror then Stripe

Even number of disks (≥4) are mirrored in pairs, then striped.

Usable capacity is N/2; offers high performance and high reliability.

RAID 0+1 – Stripe then Mirror

Performance similar to RAID 10, but reliability is lower because the entire stripe set must fail before data is lost.

Less commonly used.

Advantages of Disk Arrays

Hardware RAID

Hardware RAID uses a dedicated RAID controller card with its own processor and cache, offloading RAID calculations from the host CPU and often supporting hot‑swap of disks. The controller provides better performance for parity calculations and can continue operating while disks are replaced.

RAID Controller

Implements RAID functionality on a separate board.

Contains I/O processor, disk connectors, cache memory, etc.

Supports various RAID levels (e.g., 0, 1, 5, 10) and interfaces such as IDE, SCSI, SATA, SAS.

Controller Cache

Acts as a buffer between the disks and the system bus.

Cache size and speed directly affect the RAID card’s throughput.

Typical capacities range from a few megabytes to several hundred megabytes.

Software RAID Configuration (Linux)

Below is a practical example of creating a RAID 5 array on a Linux server using the mdadm utility.

Prerequisites

Add four SCSI disks to the VM.

Install the mdadm package.

Step 1 – Verify mdadm Installation

Run rpm -q mdadm; if not installed, use yum install -y mdadm.

Step 2 – Partition Disks (type fd)

Modify /dev/sdb, /dev/sdc, /dev/sdd and /dev/sde as shown in the screenshots.

Step 3 – Create RAID 5 Device

# format
mdadm -C -v /dev/md0 -a yes -l5 -n3 /dev/sd[bcd]1 -x1 /dev/sde1

Step 4 – View RAID Details

# Two ways to check creation progress:
cat /proc/mdstat
mdadm -D /dev/md0
# Dynamic view every 5 seconds
watch -n 5 'cat /proc/mdstat'
# Check if a disk is already part of RAID
mdadm -E /dev/sdb1

Step 5 – Format and Mount the Array

# format
mkfs -t xfs /dev/md0
# temporary mount
mount /dev/md0 /opt/

Step 6 – Simulate Disk Failure

Create files on the mounted directory, then mark a disk as failed and observe the rebuild process.

Step 7 – Create mdadm Configuration File

# echo 'DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1' > /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf

Step 8 – Stop and Start RAID

Common mdadm options:

-r : remove device
-a : add device
-S : stop RAID
-A : start RAID
mdadm /dev/md0 -f /dev/sdc1   # mark as failed
mdadm /dev/md0 -r /dev/sdc1   # remove
mdadm /dev/md0 -a /dev/sdc1   # add

Step 9 – Stop and Restart Example

mdadm -S /dev/md0
mdadm -As /dev/md0   # -s searches /etc/mdadm.conf for configuration
Copyright © CSDN author "码海小虾米_". This article is licensed under CC 4.0 BY‑SA. Original link: https://blog.csdn.net/weixin_45551608/article/details/115866752
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxHardwarestoragesoftwareRAIDmdadm
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.