These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX02/What Is Software RAID

Classnotes | UNIX02 | RecentChanges | Preferences

The one thing to bear in mind with respect to the corresponding chapter in the book is that it deals with 2.2 Linux kernels, which are several years outdated.

What is RAID?

RAID stands for redundant arrays of independent/inexpensive disks. The basic premise behind RAID is the joining of two or more disks together to form some larger array. There are several levels of RAID devices,

  • Linear mode
    • Two or more disks are combined into one physical device. The disks are ``appended'' to each other, so writing linearly to the RAID device will fill up disk 0 first, then disk 1 and so on. The disks does not have to be of the same size.
    • There is no redundancy in this level. If one disk crashes you will most probably lose all your data. You can however be lucky to recover some data, since the filesystem will just be missing one large consecutive chunk of data.
    • The read and write performance will not increase for single reads/writes. But if several users use the device, you may be lucky that one user effectively is using the first disk, and the other user is accessing files which happen to reside on the second disk. If that happens, you will see a performance gain.

  • RAID-0
    • Also called ``stripe'' mode. The devices should (but need not) have the same size. Operations on the array will be split on the devices. If one device is much larger than the other devices, that extra space is still utilized in the RAID device, but you will be accessing this larger disk alone, during writes in the high end of your RAID device. This of course hurts performance.
    • Like linear, there is no redundancy in this level either. Unlike linear mode, you will not be able to rescue any data if a drive fails. If you remove a drive from a RAID-0 set, the RAID device will not just miss one consecutive block of data, it will be filled with small holes all over the device. e2fsck or other filesystem recovery tools will probably not be able to recover much from such a device.
    • The read and write performance will increase, because reads and writes are done in parallel on the devices. This is usually the main reason for running RAID-0.

  • RAID-1
    • This is the first mode which actually has redundancy. RAID-1 can be used on two or more disks with zero or more spare-disks. This mode maintains an exact mirror of the information on one disk on the other disk(s). Of Course, the disks must be of equal size. If one disk is larger than another, your RAID device will be the size of the smallest disk.
    • If up to N-1 disks are removed (or crashes), all data are still intact. If there are spare disks available, and if the system (eg. SCSI drivers or IDE chipset etc.) survived the crash, reconstruction of the mirror will immediately begin on one of the spare disks, after detection of the drive fault.
    • Write performance is often worse than on a single device, because identical copies of the data written must be sent to every disk in the array. With large RAID-1 arrays this can be a real problem, as you may saturate the PCI bus with these extra copies.

  • RAID-4
    • This RAID level is not used very often. It can be used on three or more disks. Instead of completely mirroring the information, it keeps parity information on one drive, and writes data to the other disks in a RAID-0 like way. Because one disk is reserved for parity information, the size of the array will be (N-1)*S, where S is the size of the smallest drive in the array. As in RAID-1, the disks should either be of equal size, or you will just have to accept that the S in the (N-1)*S formula above will be the size of the smallest drive in the array.
    • If one drive fails, the parity information can be used to reconstruct all data. If two drives fail, all data is lost.
    • The reason this level is not more frequently used, is because the parity information is kept on one drive. This information must be updated every time one of the other disks are written to. Thus, the parity disk will become a bottleneck, if it is not a lot faster than the other disks. However, if you just happen to have a lot of slow disks and a very fast one, this RAID level can be very useful, contrary to what the book says.

  • RAID-5
    • This is perhaps the most useful RAID mode when one wishes to combine a larger number of physical disks, and still maintain some redundancy. RAID-5 can be used on three or more disks, with zero or more spare-disks. The resulting RAID-5 device size will be (N-1)*S, just like RAID-4. The big difference between RAID-5 and -4 is, that the parity information is distributed evenly among the participating drives, avoiding the bottleneck problem in RAID-4.
    • If one of the disks fail, all data is still intact, thanks to the parity information. If spare disks are available, reconstruction will begin immediately after the device failure. If two disks fail simultaneously, all data are lost. RAID-5 can survive one disk failure, but not two or more.
    • Both read and write performance usually increase, but can be hard to predict how much. Reads are similar to RAID-0 reads, writes can be either rather expensive (requiring read-in prior to write, in order to be able to calculate the correct parity information), or similar to RAID-1 writes. The write efficiency depends heavily on the amount of memory in the machine, and the usage pattern of the array. Heavily scattered writes are bound to be more expensive.

Software RAID

Linux has builtin ability to perform RAID tasks on drives connected to it. It can produce RAID solutions that can be more reliable than hardware based RAID arrays (hardware based arrays may become unusable if you have failure of the RAID card, whereas Linux software based arrays will always remain usable). The only advantage to using a hardware based array would be in solving the speed problems associated with RAID-1 - if you use a hardware RAID card, the extra write copies of the data will not have to go over the PCI bus, since it is the RAID controller that will generate the extra copy. Read performance is good, especially if you have multiple readers or seek-intensive workloads.

As a result, most Linux professionals will actually recommend software-based RAID over hardware-based in most circumstances because you get better reliability at a much lower cost.

NOTE: What you may not realize is that most low to mid-range RAID cards are actually not true-hardware RAID cards. Many of them (for example, the Rocketpoint cards) actually offload much of the RAID work onto the OS and wind-up being software-based RAIDs that are even less reliable than true hardware based ones!

For more information, see the Software-RAID HOWTO:

Classnotes | UNIX02 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited September 13, 2003 3:00 pm (diff)
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.