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
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Operating Systems.
Lesson complete
Earn the 3 college credits for Introduction to Operating Systems
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: The Storage Beneath File Systems →← 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 →
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.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: Linux vs Operating Systems
Why take it here
Why students take Introduction to Operating Systems with UPI Study
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.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →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?
How does RAID 5 parity rebuild a failed drive?
How much usable space does RAID 5 give with four 2 TB drives?
Is RAID a replacement for backups?
About the Introduction to Operating Systems course
How many college credits is Introduction to Operating Systems?
How much does Introduction to Operating Systems cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Operating Systems take?
How are the exams done?
How do my credits reach my college?
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
3 credits · NCCRSEnroll →