The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
 

 RAID

1.0 RAID - Redundant Array of Inexpensive Disksy
            Hardware-RAID
            Software RAID
            Semi-Hardware-RAID
        Choosing RAID Hard Drives
        RAID Levels
           RAID 0 (stripe)
           RAID 1 (mirror)
               RAID Downgrading
               Spare Disk, Reserve Drive
           RAID 5
               Unrecoverable Errors in RAID 5
           RAID 6
           Hybrid RAID
1.1 Linux Software RAID
       mdadm : Creating/Managing Software RAID
           Create Mode, Establishing Software RAID
                Editing RAID Configuration File /etc/mdadm.conf
                Monitoring Soft RAID in /proc/mdstat
          Manage Mode, Managing Software RAID
          Assemble Mode, Restarting Previously Created RAID
          Monitor Mode, Monitoring Software RAID
          Grow Mode, Changing RAID Size
          Miscellaneous Mode
          Generic Mode
       Creating Hybrid RAID Using mdadm


ENG⇒中ENG⇒中
 
 1.0 RAID - Redundant Array of Inexpensive Disksy
RAID stands for Redundant Array of Inexpensive Disks or Redundant Array of Independent Disks. The term "Redundant" in the dictionary denotes something excessive or superfluous. However, in the context of RAID, it serves the purpose of backup and fault tolerance. This means that different combinations of redundant hard drives are used to achieve functions such as backup, fault tolerance, and even acceleration. The merging of multiple hard drives into a single virtual device is referred to as RAID.

RAID can be categorized based on its functions, including acceleration, increased capacity, backup, or fault tolerance. Different RAID levels can be configured to meet various needs. The formation of these different RAID levels can be achieved using hardware, known as Hardware RAID. It can also be accomplished using software, known as Software RAID. There is also a hybrid option called Semi-Hardware RAID, which combines aspects of both hardware and software. The advantages and disadvantages of each approach are as follows:




Choosing RAID Hard Drives
Many people might think that RAID already provides basic backup and fault tolerance capabilities, so they choose cheap hard drives. While this might be acceptable for practice purposes, when deploying RAID for professional use, there are several important considerations when selecting hard drives. First and foremost, you need to consider the hard drive's error correction mechanism.

In general, when a regular hard drive detects instability in a certain magnetic area during operation, it will "freeze" momentarily and secretly move the data from the unstable area to a reserved area. After the transfer is complete, the unstable area is blocked, and the reserved area is opened up. As a result, the total capacity remains unchanged (referred to as "deep recovery cycle" in Western Digital's terminology). Through this process, the hard drive effectively performs a "Grand Relocation" of data, which might appear as a momentary pause to the average user, causing minimal disruption.

However, both Hardware RAID and Software RAID treat any hard drive that doesn't respond within 8 to 30 seconds during data writing as a faulty drive and eject it from the RAID array. While the "deep recovery cycle" doesn't happen frequently, in applications that operate 24/7 for a year, it is likely to occur a few times. This behavior is not limited to mechanical hard drives; even SSDs (Solid-State Drives) with their limited write-cycle lifespan due to NAND Flash rely on this type of self-repair mechanism.

Taking Western Digital's consumer-grade desktop hard drives (Blue, Green, Black series) as an example, the "freeze" during the execution of the "deep recovery cycle" can last up to 2 minutes. If this happens in a RAID setup, the hard drive would have been already ejected from the RAID array due to the extended response time. However, Western Digital's enterprise-grade hard drive series (such as Velociraptor and RAID Edition Re) are equipped with "TLER" (Time-Limited Error Recovery) functionality, which ensures that the "freeze" during error correction won't exceed 7 seconds, preventing the drive from being kicked out of the RAID array.[Note 1.0]

Not only Western Digital, but other brands of enterprise-grade hard drives like Seagate, Toshiba, and Hitachi also have similar mechanisms, though the terms used might differ (such as ERC - Error Recovery Control or CCTL - Command Completion Time Limit). Therefore, when setting up a RAID, it's crucial to spend some time checking the specifications on the hard drive manufacturer's website. If you're setting up a RAID 5, you should also consider "URE" (Unrecoverable Read Errors) and aim to minimize potential RAID 5 unrecoverable errors. It's not just about price and capacity; otherwise, you might end up with unexpected issues.

In general, hard drives suitable for setting up RAID are of "enterprise-grade" or "NAS-grade", which offer support for "TLER" (Time-Limited Error Recovery) functionality and lower levels of "unrecoverable read error."



^ back on top ^

RAID-Levles
Different numbers of hard drives or partitions can be organized into various RAID levels based on their functions, achieving functionalities such as acceleration, increased capacity, backup, or fault tolerance. Furthermore, the addition of more hard drives can result in hybrid RAID configurations that combine multiple functionalities, such as acceleration + fault tolerance or increased capacity + backup. Cheaper hardware RAID or Fake RAID solutions may have limited support for certain RAID levels. While standard RAID levels range from RAID 0 to RAID 6, RAID 2 to RAID 4 are theoretically viable but not practical in real-world scenarios and are rarely commercially implemented, so they are omitted from discussion.


^ back on top ^


   1.1 Linux Soft RAID
Although Software RAID offers convenient and quick management without the need for hardware RAID, it will never disappear due to its "cost-free" nature. Another advantage is its flexibility, allowing for the free combination of different RAID levels and the utilization of partitions to create RAID arrays or even complex assemblages. For example, it is possible to create a RAID using a mix of hard drives with various interfaces such as IDE, SATA, SCSI, USB, M.2 etc. This is something that Hardware RAID cannot achieve. Furthermore, some entry-level hardware RAID controllers might only support limited RAID levels. For instance, Dell's entry-level RAID Controller (PERC) H200 only supports RAID 0, RAID 1, and RAID 10. However, it's worth mentioning that running RAID 0, RAID 1, and RAID 10 using Software RAID doesn't necessarily result in slower performance compared to Hardware RAID, as RAID 0 and RAID 1 fundamentally involve minimal computational overhead.


mdadm - Creating/Managing Software RAID
The commandmdadm stands for "multiple disk devices admin" and is an abbreviation used for creating, managing, and monitoring Software RAID on Linux systems. The terms "md" (multiple disk devices) and "dm" (in /dev/mapper/) like in LVM or kpartx, both refer to virtual storage devices.

mdadm is a versatile command used for creating, managing, and monitoring Software RAID. For detailed usage instructions, you can refer to the man mdadm command. Below, I'll introduce the commonly used modes: createmanageassemblemonitorgrow, and misc.



Creating Hybrid RAID Using mdadm
Common and useful hybrid RAID configurations include RAID 10, RAID 50, and RAID 60. Some distributions support a shorthand notation like --level=10 for RAID 10. For instance, the following command creates a RAID 10 configuration:

Example:
# mdadm -v --create /dev/md0 --level=raid10 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde ←Create RAID 10

While the above approach is convenient, it might not be clear which disk serves as the stripe and which acts as the mirror. Therefore, it's recommended to build step by step. For instance, creating a RAID 50 involves first building two RAID 5 arrays, and then combining these RAID 5 arrays into a RAID 0 array, resulting in RAID 50.

Example:
# mdadm --create /dev/md0 --raid-devices=3 --level=5 /dev/sdb1 /dev/sdc1 /dev/sdd1
  ↑ First, create a RAID 5 array
# mdadm --create /dev/md1 --raid-devices=3 --level=5 /dev/sde1 /dev/sdf1 /dev/sdg1
  ↑ Create another RAID 5 array
# mdadm --create /dev/md3 --raid-devices=2 --level=0 /dev/md0 /dev/md1
  ↑ Combine the two RAID 5 arrays into a RAID 0 array, creating RAID 50

In this approach, you build the RAID configuration in layers, starting from the basic RAID levels and combining them as needed to achieve the desired hybrid RAID configuration

^ back on top ^




   
[Note1.0] Reference source WD Knowledge Base: Chinese: http://wdc-tw.custhelp.com/app/answers/detail/a_id/7019/session/L3RpbWUvMTQwNzk0ODcyMy9zaWQvLUxSSm9MX2w%3D
English: http://wdc.custhelp.com/app/answers/detail/a_id/1397/p/227,283/session/L3RpbWUvMTMyMTQzOTc4NS9zaWQvdVhvYmpmSms%3D


[Note 1.1] Hard drives with IDE interfaces do not support hot-plugging. Hard drives with SCSI/SAS/SATA/eSATA/USB interfaces may support hot-plugging, but the support depends on the hardware's documentation.