RAID, Explained | Introduction to Operating Systems

UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 5.12 Free with a free account

RAID

Introduction to Operating Systems · Chapter 5: Peripheral Devices and I/O SystemsSection 5.12 · lesson 47 of 839 min · free with a free account

← Flash MemoryNext lesson: The Storage Beneath File Systems →

A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →

Earn 3 college credits for Introduction to Operating SystemsRecommended for credit by NCCRS · Computer Science 354 · self-paced · one payment, lifetime access

In this lesson

How striping, mirroring and XOR parity let drive arrays survive failures.

  • Explain striping, mirroring and parity and how RAID combines them
  • Compare usable space and failure tolerance for RAID 0, 1, 5, 6 and 10
  • Use XOR to rebuild a lost block from the remaining data and parity
  • Explain why RAID protects against drive failure but is not a backup

Free study notes

Get this lesson's notes by email

The key points and 4 practice questions with answers, in your inbox. One email, free.

One email. Unsubscribe in one click.

Transcript

Everything said in the video, section by section (1,205 words). Read along, or search it.

Opening Scene

One Disk Clicks and Goes Quiet

Sam, who runs a small online bakery, keeps every order, recipe, and photo on one hard disk in the shop's server. One morning, it clicks twice, and goes quiet. If that disk had a twin holding the same data, the shop could simply carry on. That's the big idea behind RAID: use several drives together, so that one dead drive is an inconvenience, not a disaster. But which way gives the most space, and the most safety? And how can a lost drive come back from a little arithmetic?

Definition

Many Drives Seen as One Volume

RAID stands for Redundant Array of Independent Disks. In the 1988 Berkeley paper that named it, the I meant inexpensive. It joins several drives, so the operating system sees one big drive, called a volume. RAID can come from a special controller card, or from the operating system's own software. Either way, the OS stays simple. It sees one volume, just as it saw one drive behind the SSD controller in lesson 5.11.

Building Blocks

Striping, Mirroring and Parity

RAID mixes three basic tricks. Striping splits data into blocks, and spreads them across the drives, like dealing cards. Several drives work at once, so reads and writes can be faster. Mirroring writes the same data to two or more drives. If one dies, a copy is still there. And parity stores a small piece of extra information, computed from the data, so a lost block can be rebuilt from the others. It costs less space than a full copy.

RAID 0 and 1

Pure Striping Versus Pure Mirroring

RAID 0 is pure striping. A file's blocks alternate across the drives, so each drive carries part of the work, and you keep all the space. But there's no redundancy at all. If any one drive dies, part of every big file is gone. RAID 0 is really fast, and fragile. RAID 1 is mirroring. Every block is written to each drive, so any one drive alone holds everything. It's safe and simple. But with two drives, half the space is spent on copies.

Quick Check

Two Drives in RAID 0

Quick check. A video editor puts two four terabyte drives into RAID 0. How much space is usable, and how many drive failures can it survive? Pause, and decide. Eight terabytes, and it survives no failures. Striping keeps all the space, and stores nothing twice. Eight terabytes surviving one is the tempting mix-up: two drives feel like a spare. But every big file has blocks on both drives, so losing either one loses data. And four terabytes surviving one describes RAID 1.

RAID 5

Rotating Parity Across Three or More Drives

RAID 5 needs at least three drives. Each row, called a stripe, has data blocks on every drive but one, and a parity block on that last one. The parity block's position rotates from row to row, so no single drive does all the parity work. The cost is one drive's worth of space. And any one failed drive can be survived.

How Parity Works

XOR Undoes Itself

How can a parity block rebuild a lost one? It's computed with XOR, short for exclusive or: a bit operation that gives one when two bits differ, and zero when they match. XOR has a lovely property. XOR the same thing in twice, and you're back where you started. So if the parity is A, XOR B, XOR C, then B is A, XOR C, XOR the parity. Try it with four bits. One zero one zero, XOR zero one one zero, gives a parity of one one zero zero. Now lose the second value. One zero one zero, XOR the parity, one one zero zero, gives zero one one zero. It's back.

Worked Example

Rebuilding SHOP From Parity Bytes

Here it is with real bytes. Three drives hold the words BAKE, SHOP, and 2026, and a fourth holds their parity, byte by byte. Now drive two fails. XOR the other three together, and SHOP comes back: fifty-three, forty-eight, four F, fifty. No copy of it was ever stored. The same rule works whichever drive is lost, even the parity drive itself.

Quick Check

Recovering a Lost Value With XOR

Quick check. A tiny array stores parity P equals A, XOR B. A is one zero zero one, and P is zero zero one one. The drive holding B has failed. What was B? Pause, and work it out. One zero one zero. B is A, XOR P. One XOR zero is one. Zero XOR zero is zero. Zero XOR one is one. One XOR one is zero. The other two are tempting slips. One zero one one is A OR P: it sets a bit when either is one. And zero zero zero one is A AND P. Only XOR undoes itself.

RAID 6 and 10

Double Parity and Striped Mirrors

RAID 6 is like RAID 5, with two different parity blocks in each row, P and Q, so any two drives can fail at once. It needs at least four drives, and spends two drives' worth of space. That matters for big arrays. A RAID 5 array that's rebuilding after one failure is exposed: a second failure during the rebuild loses data. RAID 10, also written one plus zero, is a stripe of mirrored pairs. It combines the speed of striping with the safety of mirroring, and needs at least four drives.

Comparison

Four Drives, Five Levels Compared

Now compare them with four drives of two terabytes each: eight terabytes raw. A program tried every possible set of failed drives, so these survival numbers come from checking, not from a formula. RAID 0 gives all eight terabytes, but survives nothing. RAID 5 gives six, and survives one failure. RAID 6 gives four, and survives any two. RAID 10 gives four. It always survives one failure, and a second only if it hits the other pair. That's why its best case says two, but always says one. And RAID 1 here means all four drives mirror each other: two terabytes usable, and three can fail.

Choosing a Level

Pick by What You Fear Most

So to pick a level, ask what you fear most. Lost speed? RAID 0, but only for data you can recreate. A lost drive? RAID 1, 5, 6, or 10. Lost space? RAID 5 wastes the least while still protecting. And slow writes in a busy database? RAID 10 avoids the parity work.

Key Warning

RAID Cannot Undo a Deletion

Now the most important warning. RAID protects against one thing: a drive dying. It doesn't protect against deleting the wrong file, a virus or ransomware that encrypts everything, a power surge or fire that harms every drive, or a controller that fails. In all of these, a mirror or a parity block faithfully copies the damage. A mirrored drive happily mirrors a deletion within a second. A backup is a separate copy, kept elsewhere, ideally with older versions you can go back to. Lessons 9.1 and 9.5 return to these threats and habits.

Real Example

Choosing RAID 5 for the Bakery Server

Back to Sam. The bakery's new server got four two terabyte drives. Make it all mirrored, Sam said. Ivy, who looks after the computers at a school, showed the numbers. Four mirrored drives give you two terabytes. RAID 5 gives six, and still survives one failure. Sam picked RAID 5, and also kept a weekly copy on a separate drive, in the safe. RAID keeps you running, Ivy said. The safe copy brings you back.

Key Takeaways

Levels Trade Space for Safety

To recap. RAID mixes striping for speed, mirroring for copies, and parity for rebuilding. Levels trade space for safety: 0, 1, 5, 6, and 10. XOR parity rebuilds any one lost block. And RAID is not a backup.

About Introduction to Operating Systems at UPI Study

Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.

Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Compare: Linux vs Operating Systems

Why take it here

Why students take Introduction to Operating Systems with UPI Study

What happens under every app you runIntroduction to Operating Systems explains the software that runs a computer: processes and scheduling, threads and synchronization, deadlock, memory and paging, devices and storage, file systems, networking, security and virtualization. It suits computer science and information technology degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Where the credit goes

Universities that work with NCCRS

Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.

FAQ

Questions students ask us

About RAID

What does RAID stand for?
RAID stands for Redundant Array of Independent Disks, and the 1988 Berkeley paper that named it used Inexpensive in place of Independent. A RAID setup joins several drives so the operating system sees one large volume. It can be built by a dedicated controller card or by the operating system's own software, and it mixes striping, mirroring and parity to trade space, speed and safety.
How does RAID 5 parity rebuild a failed drive?
RAID 5 rebuilds a lost block by XORing the surviving blocks in the same stripe with the parity block. XOR gives one when two bits differ and zero when they match, and applying the same value twice cancels it out. If parity equals A XOR B XOR C, then B equals A XOR C XOR parity, so the missing data can be recomputed without any stored copy.
How much usable space does RAID 5 give with four 2 TB drives?
RAID 5 with four 2 TB drives gives 6 TB of usable space and survives one drive failure. One drive's worth of space goes to parity, spread across the drives. For comparison, the same four drives give 8 TB with no protection in RAID 0, 4 TB in RAID 6 with any two failures survivable, and 4 TB in RAID 10.
Is RAID a replacement for backups?
No, RAID is not a backup, because it protects against a drive dying and little else. A mirror or parity array faithfully copies an accidental deletion or ransomware encryption across its drives within seconds, and a fire or power surge can damage every drive together. A real backup is a separate copy kept elsewhere, ideally with older versions to restore from.

About the Introduction to Operating Systems course

How many college credits is Introduction to Operating Systems?
Introduction to Operating Systems (Computer Science 354) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Introduction to Operating Systems cost and what is included?
$250, paid once, with lifetime access: all 83 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Introduction to Operating Systems take?
It is self-paced with no deadlines. The 83 lessons total about 10 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

Ready for the full course? Earn 3 credits in Introduction to Operating Systems.

83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.

Updated

Introduction to Operating Systems
3 credits · NCCRS
Enroll →