Skip to main content
RunBook Academy

LinuxXVII · Software RAIDRAID levels

RAID5 and RAID6 - parity for capacity and fault tolerance

Intermediate⏱ ~10 minbashmdadmlsblkmount

What you'll learn

  • Explain how RAID5 and RAID6 calculate and store parity
  • Create a RAID5 array with mdadm
  • Understand the rebuild trade-offs for large disks
  • Explain the RAID5 write hole and choose a mitigation (RAID10, PPL, write journal, BBU)
  • Detect an open write hole with a scrub and mismatch_cnt
  • Choose between RAID5 and RAID6 for production

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

RAID5 and RAID6 are the workhorses of production data storage. They give the capacity advantage of striping plus fault tolerance through parity. The trade-off is the rebuild: a failed disk must be reconstructed from the parity, and the rebuild time scales with disk size.

How parity works

The write hole

Mitigations, in order of preference:

  • Use RAID10 for anything where silent corruption is unacceptable - database volumes above all.
  • Enable PPL on a RAID5 array. The Partial Parity Log lives in the metadata region of the members, so it needs no extra device: mdadm --create ... --consistency-policy=ppl. man 8 mdadm describes it as closing the write hole and eliminating resync.
  • Use a write journal on a small, power-safe SSD: mdadm --create ... --write-journal /dev/nvme0n1p1. md logs each stripe transaction and replays it after an unclean shutdown. Stronger than PPL, and available for RAID4/5/6, but the journal device becomes a dependency of the array.
  • A hardware controller with a healthy BBU or supercapacitor write cache does the same job in firmware - provided the battery is actually good. Monitor it.
  • A UPS with a tested automatic shutdown. Necessary, not sufficient: it does nothing for a PSU failure or a kernel panic.

Creating a RAID5 array

Data-loss riskcreate RAID5
$ mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Creating a RAID6 array

Data-loss riskcreate RAID6
$ mdadm --create /dev/md0 --level=6 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

The rebuild trade-off

Read-only / Saferebuild in progress
$ cat /proc/mdstat
Personalities : [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sde[4] sdd[3] sdc[2] sdb[1]
6287424 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU]
[==>..................]  recovery = 8.5% (178176/2095808) finish=2.3min speed=13896K/sec
bitmap: 1/1 pages [4KB], 65536KB chunk

Adding a hot spare

Data-loss riskadd hot spare
$ mdadm /dev/md0 --add-spare /dev/sdf
mdadm: added /dev/sdf as spare

Knowledge check

Knowledge check · 5 questions

  1. Q1. How many disks can a RAID6 array lose simultaneously without data loss?

  2. Q2. A RAID5 rebuild on a 10 TB disk can take more than 24 hours.

  3. Q3. Which of the following are correct for RAID5/RAID6? Select all that apply.

  4. Q4. A host on mdadm RAID5 loses power mid-write. It boots, the array reports clean, and no errors appear anywhere. What is the actual risk you have just inherited?

  5. Q5. You are specifying storage for a business-critical database on a host in a small office with no UPS and no battery-backed controller. Capacity budget allows either 6-disk RAID6 or 6-disk RAID10. Which do you choose, and why?

Passing score: 75%. Answers are checked in this browser.