Home > Articles

This chapter is from the book

Understanding RAID

RAID (Redundant Array of Independent Disks) allows an administrator to form an array of several hard drives into one logical drive recognized as one drive by the operating system. It also spreads the data stored over the array of drives to decrease disk access time and accomplish data redundancy. The data redundancy can be used to recover data should one of the hard drives in the array crash.

There are two types of RAID: hardware RAID and software RAID. Hardware RAID is implemented through the disk controller for the system. Instructions for configuring hardware RAID differ from controller to controller, so refer to the manual for your disk controller for instructions. Software RAID is implemented through the operating system and does use some processor and memory resources, although some software RAID implementations can produce faster disk access times than hardware RAID.

During installation, it is possible to configure software RAID as discussed in Chapter 1. This section explains the different RAID levels available with software RAID so you can decide which level is best for you. Software RAID allows for RAID levels 0, 1, 5, and 6.

RAID level 0, or striping, means that data is written across all hard drives in the array to accomplish the fast disk performance. No redundancy is used, so the size of the logical RAID drive is equal to the size of all the hard drives in the array. Because there is no redundancy, recovering data from a hard drive crash is not possible through RAID.

RAID level 1, or mirroring, means that all data is written to each disk in the array, accomplishing redundancy. The data is “mirrored” on a second drive. This allows for easy recovery should a disk fail. However, it does mean that, for example, if there are two disks in the array, the size for the logical disk is size of the smaller of the two disks because data must be mirrored to the second disk.

RAID level 5 combines striping and parity. Data is written across all disks as in RAID 0, but parity data is also written to one of the disks. Should a hard drive failure occur, this parity data can be used to recover the data from the failed drive, including while the data is being accessed and the drive is still missing from the array.

RAID level 6 is RAID level 5 with dual parity. Data is written across all disks as in RAID 5, but two sets of parity data is calculated. Performance is slightly worse than RAID 5 because the extra parity data must be calculated and written to disk. RAID 5 allows for recovery using the parity data if only one drive in the array fails. Because of the dual parity, RAID 6 allows for recovery from the failure of up to two drives in the array.

Setting Up RAID Devices

For best results, software RAID should be configured during installation, but it can be configured after installation if necessary. To set up software RAID devices after installation, install the mdadm software package. Refer to Chapter 3 for instructions on installing packages. This section provides an overview of post-installation software RAID configuration. It shows you how to create a RAID array and then move the data from the existing filesystem onto it. Be sure to test the process on a test system before attempting it on a production system.

Before starting the conversion, add the appropriate number of hard drives with the proper sizes for the RAID level. For example, two partitions are needed for RAID 1 (mirroring) and at least three partitions are needed for RAID 5. To use all the benefits of RAID, each partition in a RAID device should be on separate hard drives so each member of the RAID device can be written to at the same time and there is redundancy across separate hard drives should one fail.

It is possible to configure a RAID array with a missing partition so that the data on the existing partition can be copied to the degraded array. The existing partition is reconfigured as a RAID partition and then added to the RAID array to complete it. However, the process for doing so is more complicated and not recommended because it is easier to lose the existing data. It is recommended that new drives be used to set up the RAID device and for the existing data to then be copied to the new RAID device.

When creating partitions to use for the RAID device, make sure they are of type Linux raid auto. In fdisk, this is partition id fd. After creating the partitions for the RAID device, use the following syntax as the root user to create the RAID device:

mdadm --create /dev/mdX --level=<num> --raid-devices=<num> <device list>

The progress of the device creation can be monitored with the following command as root:

tail -f /proc/mdstat

For example, to create a RAID level 1 device /dev/md0 from three partitions, use the following command:

mdadm --create /dev/md0 --level=1 --raid-devices=3 /dev/sda5 /dev/sda6 /dev/sda7

The command cat /proc/mdstat should show output similar to Listing 7.7.

Listing 7.7. Creating a RAID Array

Personalities : [raid0] [raid1]
md0 : active raid1 sda7[2] sda6[1] sda5[0]
      10241280 blocks [3/3] [UUU]
      [>....................]  resync =  0.0% (8192/10241280) finish=62.3min
speed=2730K/sec

unused devices: <none>

The RAID device /dev/md0 is created. Next, create a filesystem on it. To create an ext3 filesystem, execute the following as root:

mke2fs -j /dev/md0

If the new RAID device is to be used as the swap partition, use the following command as root instead:

mkswap /dev/md0

Copy any data over to the new device and be sure to change all references to the old partition to the new RAID device, including /etc/fstab and /etc/grub.conf. It is recommended that the /boot and the / filesystems remain on their original filesystems to ensure the system can still boot after added the RAID devices. Partitions such as /home will benefit from RAID more because data on it changes frequently.

Adding and Failing RAID Partitions

To add a partition to a RAID device, execute the following as root after creating the partition of type Linux raid auto (fd in fdisk):

mdadm /dev/mdX -a <device list>

To add /dev/sda8 to the /dev/md0 RAID device created in the previous section:

mdadm /dev/md0 -a /dev/sda8

Listing 7.8 shows the output from cat /proc/mdstat. The /dev/sda8 partition is now a spare partition in the RAID array.

Listing 7.8. Adding a Spare Partition

Personalities : [raid0] [raid1]
md0 : active raid1 sda8[3](S) sda7[2] sda6[1] sda5[0]
      10241280 blocks [3/3] [UUU]
      [>....................]  resync =  0.6% (66560/10241280) finish=84.0min
speed=2016K/sec

unused devices: <none>

If a partition in the array fails, use the following to remove it from the array and rebuild the array using the spare partition already added:

mdadm /dev/mdX -f <failed device>

For example, to fail /dev/sda5 from /dev/md0 and replace it with the spare (assuming the spare has already been added):

mdadm /dev/md0 -f /dev/sda5

To verify that the device has been failed and that the rebuild has been complete and was successful, monitor the /proc/mdstat file (output shown in Listing 7.9):

tail -f /proc/mdstat

Notice that /dev/sda5 is now failed and that /dev/sda8 has changed from a spare to an active partition in the RAID array.

Listing 7.9. Failing a Partition and Replacing with a Spare

Personalities : [raid0] [raid1]
md0 : active raid1 sda8[3] sda7[2] sda6[1] sda5[4](F)
      10241280 blocks [3/2] [_UU]
      [>....................]  recovery =  0.2% (30528/10241280) finish=11.1min
speed=15264K/sec

unused devices: <none>

Monitoring RAID Devices

The following commands are useful for monitoring RAID devices:

  • cat /proc/mdstat: Shows the status of the RAID devices and the status of any actions being performed on them such as adding a new member or rebuilding the array.
  • mdadm --query /dev/mdX: Displays basic data about the device such as size and number of spares such as:

    /dev/md0: 9.77GiB raid1 3 devices, 1 spare.

    Add the --detail option to display more data ( mdadm --query --detail /dev/mdX):

    /dev/md0:
             Version : 00.90.03
       Creation Time : Mon Dec 18 07:39:05 2006
          Raid Level : raid1
          Array Size : 10241280 (9.77 GiB 10.49 GB)
         Device Size : 10241280 (9.77 GiB 10.49 GB)
        Raid Devices : 3
       Total Devices : 4
     Preferred Minor : 0
         Persistence : Superblock is persistent
    
         Update Time : Mon Dec 18 07:40:01 2006
               State : clean, degraded, recovering
      Active Devices : 2
     Working Devices : 3
      Failed Devices : 1
       Spare Devices : 1
    
      Rebuild Status : 49% complete
    
                UUID : be623775:3e4ed7d6:c133873d:fbd771aa
              Events : 0.5
    
         Number   Major   Minor   RaidDevice State
            3       8        8        0      spare rebuilding   /dev/sda8
            1       8        6        1      active sync   /dev/sda6
            2       8        7        2      active sync   /dev/sda7
    
            4       8        5        -      faulty spare   /dev/sda5
  • mdadm --examine <partition>: Displays detailed data about a component of a RAID array such as RAID level, total number of devices, number of working devices, and number of failed devices. For example, the output of mdadm --examine /dev/sda6 shows the following:
    /dev/sda6:
              Magic : a92b4efc
            Version : 00.90.00
               UUID : be623775:3e4ed7d6:c133873d:fbd771aa
      Creation Time : Mon Dec 18 07:39:05 2006
         Raid Level : raid1
        Device Size : 10241280 (9.77 GiB 10.49 GB)
         Array Size : 10241280 (9.77 GiB 10.49 GB)
       Raid Devices : 3
      Total Devices : 4
    Preferred Minor : 0
    
        Update Time : Mon Dec 18 07:40:01 2006
              State : active
     Active Devices : 2
    Working Devices : 3
     Failed Devices : 0
      Spare Devices : 1
           Checksum : ee90b526 - correct
             Events : 0.5
    
          Number   Major   Minor   RaidDevice State
    this     1       8        6        1      active sync   /dev/sda6
    
       0     0       0        0        0      removed
       1     1       8        6        1      active sync   /dev/sda6
       2     2       8        7        2      active sync   /dev/sda7
       3     3       8        8        3      spare   /dev/sda8

Using MD Multipath

The hard drives in a system are connected to the rest of the system hardware via a disk controller. If the controller fails, the system can no longer communicate with the drives connected to it. However, some systems offer multipath disk access in which more than one controller is connected to the disks. If the active controller fails, a spare one replaces it, allowing continued access to the storage attached.

An example usage of MD Multipath is when a system is connected to a storage area network (SAN) via Fiber Channel Protocol or Cards. The multipath device can represent one interface that connects to the SAN using multiple physical cables. If one or more of the physical connections stops working or gets disconnected, the other physical cables are still active, and the storage is still accessible.

The Linux kernel offers Multiple Device (MD) Multipathing via its software RAID feature. MD Multipathing allows a device to be set up with multiple spares so that if the active device fails, I/O requests do not fail. If the active partition fails, the kernel activates one of the spare partitions as the active one.

To set up an MD Multipath device:

mdadm --create /dev/mdX --level=multipath --raid-devices=<num> <device list>

For example, use the following to set up /dev/md0 with three drives, two of which become spares:

mdadm --create /dev/md0 --level=multipath --raid-devices=3 /dev/sda1 /dev/sdc1 /dev/sdd1

The kernel monitors the failure of the partition and activates a spare when it fails. However, the mdmpd daemon from the mdadm RPM package must be running to automatically add a failed partition back to the array when it becomes available again.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020