RAID is an important storage technology for Linux administrators, but choosing the right RAID level and managing it correctly can be confusing for beginners. RAID can improve performance, provide protection against disk failure, or offer a balance of both, depending on how the disks are configured.
In this guide, you will learn how RAID works in Linux and how to manage software RAID using mdadm. We will cover RAID 0, RAID 1, RAID 5, RAID 6, and RAID 10, along with practical examples for creating arrays, checking their status, replacing failed disks, monitoring rebuilds, and expanding storage.
By the end of this guide, you will understand the differences between common RAID levels, know how to choose the right configuration for different workloads, and be able to perform essential RAID administration tasks with confidence.
Note:
If you haven't decided which filesystem sits on top of your array yet, it's worth reading through this comparison of ext4, XFS, and Btrfs first, since the choice affects how your array rebuilds and resizes later.
Linux Storage With RAID: What It Actually Is
RAID stands for Redundant Array of Independent Disks. In plain terms, it's a way of taking two or more physical drives and making the operating system treat them as one logical device, so you either get more speed, more protection against drive failure, or a mix of both depending on the level you pick.
On Linux this is mostly handled by mdadm, the software RAID tool built into the kernel's md driver. There's also hardware RAID, where a physical controller card does the work instead of the CPU, but most home labs, small servers, and even a lot of production boxes these days lean on mdadm because it's free, well understood, and doesn't lock you into a specific controller vendor.
Think of it like this. If you keep a single copy of an important document on your desk and the desk catches fire, it's gone. RAID1 is like keeping a photocopy in another room. RAID5 is more like keeping enough notes scattered around that you could reconstruct the document even if one room burned down, but not two. This guide walks through all five levels you'll actually run into in practice: RAID0, RAID1, RAID5, RAID6, and RAID10.
Once you've built a few arrays, the same logic shows up again the moment you start reading disk usage with df across mounted volumes, since your array shows up there just like any other block device.
mdadm Syntax and How It's Structured
Most mdadm commands follow a pattern that looks intimidating the first time and then becomes muscle memory after about the third array you build.
LinuxTeck.com
sudo mdadm --create /dev/md0 \
# which raid level to build
--level=1 \
# how many disks make up the array
--raid-devices=2 \
# the actual disks or partitions
/dev/sdb1 /dev/sdc1
Read it left to right and it basically says: build a new array at this device path, using this RAID level, with this many disks, made up of these specific partitions. The order of the flags rarely matters, but the disk list at the end always has to match the number you gave --raid-devices, or mdadm will just refuse and tell you so.
Note:
mdadm will sometimes still ask "Continue creating array?" even when everything looks correct. That's not an error, it's just mdadm double checking because it found existing filesystem signatures on the disks. Say yes only if you're sure those disks are empty.
mdadm Flags Worth Knowing
| Flag | What It Does | When to Use It |
|---|---|---|
| --create | Builds a brand new array from listed devices | First time setup on fresh or wiped disks |
| --level | Sets which RAID type to build (0, 1, 5, 6, 10) | Every time you create an array, no default exists |
| --raid-devices | Tells mdadm how many active disks to expect | Must match the disk count you list afterward |
| --detail | Prints full state, health, and member disks | Whenever you need to confirm array health |
| --fail | Manually marks a member disk as failed | Testing failover or pulling a suspect drive |
| --remove | Removes a failed disk from the array roster | Right before physically swapping the drive |
| --add | Adds a replacement or spare disk to an array | After swapping hardware, to trigger a rebuild |
| --assemble --scan | Reassembles arrays it finds by scanning devices | After a reboot where arrays didn't auto mount |
RAID Examples You'll Actually Use
I. Check whether mdadm is already installed
Before anything else, confirm mdadm exists on the box. A lot of minimal server images skip it entirely.
LinuxTeck.com
II. Install mdadm on Ubuntu and Rocky Linux
If it's missing, the install is a one liner on either family, just the package manager changes.
LinuxTeck.com
sudo apt update && sudo apt install -y mdadm
# Rocky Linux, RHEL, Alma
sudo dnf install -y mdadm
III. List the disks before you touch anything
Always confirm which device names actually belong to the disks you intend to use. Naming disks wrong is how people wipe the wrong drive.
LinuxTeck.com
Tip:
Run this before every array build, not just the first one. Disk letters can shift after a reboot, especially on cloud instances, and building an array on the wrong disk is not something you undo casually.
IV. Build a RAID 0 array for raw speed
RAID0 stripes data evenly across every disk in the array, so reads and writes get split up and run in parallel. It's the fastest level on paper, but there's a catch worth understanding before you touch it.
LinuxTeck.com
Warning:
RAID0 has zero redundancy. If any single disk in the array fails, you lose everything on the array, not just the data on that disk. Only use it for scratch space, temporary render caches, or data you already have backed up somewhere else.
V. Build a RAID 1 mirror for a small but important volume
This is usually the first array people build, since it protects a single important drive with a copy.
LinuxTeck.com
VI. Build a RAID 5 array for a file server
This is where most enterprise storage lives, since you get decent capacity and can still survive one disk dying.
LinuxTeck.com
/dev/sdb /dev/sdc /dev/sdd /dev/sde
VII. Build a RAID 6 array for high-redundancy storage
RAID6 works like RAID5 but keeps two independent parity blocks instead of one, spread across the disks. That means the array survives two disks failing at the same time, not just one, which matters more than people expect once drives get into the multi-terabyte range and rebuilds start taking a long time.
LinuxTeck.com
/dev/sdb /dev/sdc /dev/sdd /dev/sde
Tip:
RAID6 costs you the capacity of two disks instead of one, since it needs two parity blocks. On a 4 disk array that's a big chunk of your total space, so it makes the most sense once you're running 6 or more disks where the capacity hit becomes proportionally smaller.
VIII. Build a RAID 10 array for a database workload
Databases and virtual machines both want fast random reads and writes. RAID10 gives you that plus redundancy, at the cost of losing half your raw capacity.
LinuxTeck.com
/dev/sdb /dev/sdc /dev/sdd /dev/sde
IX. Check array status right after creation
The array starts syncing in the background the moment it's created. This is the command you'll run more than any other while learning RAID.
LinuxTeck.com
Note:
The [UUUU] means all four members are Up. If a disk fails you'll see an underscore in its place, like [UUU_], and that's your signal something needs attention.
X. Save the array so it survives a reboot
Without this step, mdadm may not reassemble your array automatically the next time the box restarts, which is a nasty surprise during a maintenance window.
LinuxTeck.com
sudo mdadm --detail --scan | sudo tee /etc/mdadm/mdadm.conf
# rebuild initramfs so boot time knows about the array
sudo update-initramfs -u
Tip:
On Rocky Linux and RHEL the config file lives at /etc/mdadm.conf instead, and the initramfs rebuild command is dracut -f. Same idea, different filenames.
XI. Simulate a failed disk and replace it
This is worth practicing on a test array before you ever face it for real. Knowing the sequence cold is what keeps a 3am incident calm instead of chaotic.
LinuxTeck.com
sudo mdadm /dev/md0 --fail /dev/sdc
# take it out of the array roster
sudo mdadm /dev/md0 --remove /dev/sdc
# add the replacement drive, rebuild starts automatically
sudo mdadm /dev/md0 --add /dev/sdf
XII. Watch a rebuild in progress, live
Once you've added the replacement, keep an eye on the resync so you know roughly when the array is safe again.
LinuxTeck.com
XIII. Grow a RAID5 array by adding one more disk
This is a real scenario for anyone who started small and ran out of space. It works, but it's slow and heavy on I/O, so plan it for a quiet window.
LinuxTeck.com
sudo mdadm --add /dev/md1 /dev/sdg
# tell mdadm to reshape into using it
sudo mdadm --grow /dev/md1 --raid-devices=5
Note:
A reshape can run for hours on large disks. The array stays online and usable the whole time, but performance will dip, so don't schedule it right before a busy period.
XIV. The mistake: treating RAID5 as a backup
This is the one that catches almost everyone at some point, usually right after their first disk failure goes smoothly and they get overconfident.
Warning:
RAID protects against a disk failing. It does nothing if someone runs rm -rf on the wrong folder, a ransomware script encrypts the volume, or the whole server catches fire. If your only copy of important data sits on a RAID array with no separate backup, you don't actually have a backup, you have a single point of failure with extra steps.
The fix is simple in concept even if it takes discipline to actually do. Pair your array with a real backup strategy, ideally something offsite or at least on separate hardware, and test restoring from it occasionally. If you haven't set that up yet, this rundown of Linux server backup solutions is a good place to start.
Why Getting RAID Right Actually Matters
The difference between a well planned array and a rushed one usually shows up months later, at the worst possible time. A server built on a single disk goes down completely the moment that disk dies, and depending on the workload that can mean hours of downtime, lost transactions, or a very uncomfortable conversation with whoever depends on that service.
Mastering RAID changes how you think about uptime in general. You stop treating storage as something that just works until it doesn't, and start treating it as something you actively monitor, the same way you'd keep an eye on CPU or memory. That mindset carries over naturally into building out a proper high availability cluster later on, since redundancy at the disk level is really just the first layer of the same idea applied at a bigger scale.
None of this replaces good judgment on hardware or a solid server hardening checklist, and it definitely doesn't replace backups. The official mdadm reference at man7.org is worth bookmarking too, since it covers edge cases this guide doesn't touch, particularly around external metadata formats and less common array types.
Key Points
- RAID0 has zero redundancy. It's the fastest level, but one disk failure takes the entire array down, so only use it for disposable or already-backed-up data.
- Use --raid-devices to declare the disk count and make sure the number of disks listed afterward matches it exactly, or the create command fails.
- Check /proc/mdstat first whenever something feels off with an array, it's faster than --detail and shows resync progress at a glance.
- Run mdadm --detail --scan and write the output to your mdadm config file, otherwise your array might not reassemble automatically on reboot.
- Mark a suspect disk with --fail before removing it, mdadm won't let you --remove an active healthy member.
- RAID5 tolerates one disk failure. If you're running large disks above roughly 8TB, lean toward RAID6 or RAID10 since rebuild windows get long and a second failure during rebuild is a real risk.
- RAID6 survives two disk failures at once by keeping a second parity block, at the cost of two disks' worth of capacity instead of one.
- Growing an array with --grow works live, but it's slow and I/O heavy, so schedule it during low traffic hours.
- RAID is not a backup. Pair every array with an actual offsite or separate-hardware backup plan.
Frequently Asked Questions
My mdadm --create command is stuck asking about a filesystem, what do I do?
That happens when the disk you're using still has old partition or filesystem data on it. If you're sure the disk is meant to be wiped, type y and continue. If you're not sure, stop and run wipefs or double check the disk name with lsblk first.
How long should the initial sync actually take?
Depends heavily on disk size and RAID level. A couple of 100GB test disks might sync in a few minutes, while multi-terabyte RAID5 or RAID6 arrays can take several hours. Check /proc/mdstat, it usually shows an estimated finish time once it gets going.
Can I use the array while it's still syncing?
Yes. The array is usable during the initial sync, you just won't get full redundancy protection until it completes. Writes during this window are safe, they just add to the sync workload.
I rebooted and my array disappeared, what happened?
Most likely the array details never got saved to /etc/mdadm/mdadm.conf (or /etc/mdadm.conf on Rocky Linux/RHEL), or the initramfs wasn't rebuilt after creation. Try sudo mdadm --assemble --scan first, then go back and fix the config file so this doesn't repeat.
Do I need to unmount the array before adding a replacement disk?
No, adding a replacement to a degraded array is designed to happen live. The array stays mounted and usable, mdadm just starts rebuilding onto the new disk in the background.
Which RAID level should I actually pick for a home NAS?
For two disks, RAID1 is the simplest and safest choice. For four or more disks where you want a balance of capacity and protection, RAID5 or RAID6 are the usual picks, with RAID6 being safer once your disks get into the multi-terabyte range.
From your first terminal command to advanced sysadmin skills, every guide here is written in plain English with real examples you can run right now.