Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

RAID 5 in Numbers

RAID 5 needs at least three disks. Usable capacity is the number of disks minus one, times the size of the smallest disk, and any one disk may fail.

DisksUsable capacityShare usable
3 × 4 TB8 TB67%
4 × 4 TB12 TB75%
6 × 4 TB20 TB83%

How Parity Works

Data is cut into chunks and written across the disks in stripes. For each stripe, one disk holds a parity block: the XOR of the data blocks. If data block A is 1010 and B is 0110, the parity is 1100. When the disk holding A fails, XOR of the parity and B gives 1100 XOR 0110 = 1010, which is A again.

The parity block moves to a different disk in each stripe, so no single disk handles all parity writes.

The Cost on Writes

A small write that changes part of a stripe takes four disk operations: read the old data, read the old parity, write the new data, write the new parity. This is the RAID 5 write penalty, and it makes random writes, such as those of a database, much slower than on the same disks in RAID 10. A write that fills a whole stripe avoids it, because parity is computed from the new data alone. Reads are fast: data comes from all disks at once.

While a disk is missing, every read of a block that lived on it has to be rebuilt from all other disks, so a degraded array is slow.

Long Rebuilds and the Second Failure

A rebuild reads every block of every surviving disk. On large hard disks that takes many hours: reading a 16 TB disk at 150 MB/s takes about 30 hours even with no other load, and real rebuilds compete with normal traffic. During that time the array has no redundancy, and a second failed disk means losing the array.

A smaller fault is enough as well. Many hard disk data sheets give an unrecoverable read error rate of one per 10 to the 14th power bits read, which is about 12.5 TB. A sector that cannot be read on a surviving disk leaves that stripe without a source, so a file is damaged or the rebuild stops. Disks bought together also age together, which makes a second failure during the rebuild more likely.

Run a regular consistency check, so bad sectors are found while the parity can still repair them:

echo check | sudo tee /sys/block/md0/md/sync_action

The mdadm packages of many distributions schedule such a check, monthly or weekly; confirm that yours does. A check reads every disk in full and slows the array while it runs.

The Write Hole

Data and parity are written in separate steps. If power fails or the server crashes between them, the stripe is left with parity that does not match its data, and nothing reports it. If a disk later fails, the rebuild uses that wrong parity and produces wrong data. Protection comes from closing that gap:

  • A write journal: Linux md can log writes to a separate fast device first (--write-journal).
  • Partial parity log: for RAID 5 only, md's --consistency-policy=ppl stores extra parity information on the member disks, with no extra device.
  • Hardware RAID: a controller with a battery or flash-protected cache.

Create a RAID 5 Array with mdadm

Warning: the create command overwrites every disk you list. Back up their contents and confirm the names with lsblk first.

sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd

The initial sync runs in the background and the array can be used meanwhile. Saving the configuration and mounting work as in mdadm RAID: set up software RAID on Linux.

Where RAID 5 Fits and Where It Does Not

  • Fits: mostly read workloads, file shares, and arrays of a few SSDs or small disks where rebuilds are short.
  • Large hard disks: choose RAID 6, which survives a second failure during the rebuild.
  • Databases and virtual machines: choose RAID 10, which has no parity penalty on random writes.

Other RAID Levels

  • RAID 0: striping only, no redundancy.
  • RAID 1: a mirror, every disk holds a full copy.

Capacity for other disk counts is in the RAID calculator and levels overview.

Was this answer helpful?
Loading...