Linux Labs

Storage / Stage 5 of 12

RAID 1: a disk has failed

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 8 · theory · 5 min

RAID levels

The level of an array decides how many disks can fail without data loss and how much space is left for files.

RAID joins several disks into one device. On Linux the md kernel driver assembles the array, and the mdadm utility creates and repairs it. The array's device is /dev/md0: in lsblk it sits under both disks with the type raid1, and it holds the filesystem from /srv/data. The filesystem does not see the array's disks: it reads and writes through md0, and the kernel spreads the blocks over the disks.

How to spread them is set by the array's level:

Level Disks, at least Survives the failure of Space from N disks
RAID 0, stripe 2 no disk N
RAID 1, mirror 2 all disks but one one disk
RAID 5 3 one disk N − 1
RAID 10 4 one disk in each pair N / 2

A mirror writes every block to all its disks at once and reads from any working one. That is why the files can be read from loop0 after loop1 failed, and why md0 in lsblk is the size of one disk: 127M out of 128M, the rest taken by mdadm's own record.

RAID protects against a disk failure. It does not save you from human error: a deleted file disappears from both disks at once, so backups are still needed with an array.

Check yourself 1 question

A RAID 0 of two disks was built for temporary build files. What happens to the array's files when one disk fails?

  • Parity belongs to RAID 5 and RAID 6. RAID 0 has neither copies nor parity, so there is nothing to rebuild from.

  • That is how RAID 1 works. In a stripe every block sits on one disk, and the other disk keeps no copy.

  • A stripe cuts every file into chunks and lays them across the disks in turn, so without one disk almost no file can be put back together.

In a stripe every block is stored once, and files are spread over both disks in chunks. Without one disk the array cannot be assembled and the data is lost entirely — which is why RAID 0 is used for data you can afford to lose.

Key points

  • An md array is one /dev/mdN device made of several disks: the filesystem sits on it and does not see the disks.
  • The level sets how many failures the array survives: a mirror keeps a full copy on every disk, a stripe keeps none.
  • RAID saves you from a disk failure, and only a backup saves you from a deleted file.
Ubuntu 24.04
Loading…