4.4.15. RAID Logical Volumes

As of the Red Hat Enterprise Linux 6.3 release, LVM supports RAID4/5/6 and a new implementation of mirroring. The latest implementation of mirroring differs from the previous implementation of mirroring (documented in Section 4.4.3, “Creating Mirrored Volumes”) in the following ways:
  • The segment type for the new implementation of mirroring is raid1. For the earlier implementation, the segment type is mirror.
  • The new implementation of mirroring leverages MD software RAID, just as for the RAID 4/5/6 implementations.
  • The new implementation of mirroring maintains a fully redundant bitmap area for each mirror image, which increases its fault handling capabilities. This means that there is no --mirrorlog option or --corelog option for mirrors created with this segment type.
  • The new implementation of mirroring can handle transient failures.
  • Mirror images can be temporarily split from the array and merged back into the array later.
  • The new implementation of mirroring supports snapshots (as do the higher-level RAID implementations).
  • The new RAID implementations are not cluster-aware. You cannot create an LVM RAID logical volume in a clustered volume group.
For information on how failures are handled by the RAID logical volumes, refer to Section 4.4.15.8, “Setting a RAID fault policy”.
The remainder of this section describes the following administrative tasks you can perform on LVM RAID devices:

4.4.15.1. Creating a RAID Logical Volume

To create a RAID logical volume, you specify a raid type as the --type argument of the lvcreate command. Usually when you create a logical volume with the lvcreate command, the --type argument is implicit. For example, when you specify the -i stripes argument, the lvcreate command assumes the --type stripe option. When you specify the -m mirrors argument, the lvcreate command assumes the --type mirror option. When you create a RAID logical volume, however, you must explicitly specify the segment type you desire. The possible RAID segment types are described in Table 4.1, “RAID Segment Types”.

Table 4.1. RAID Segment Types

Segment type Description
raid1 RAID1 mirroring
raid4 RAID4 dedicated parity disk
raid5 Same as raid5_ls
raid5_la
RAID5 left asymmetric.
Rotating parity 0 with data continuation
raid5_ra
RAID5 right asymmetric.
Rotating parity N with data continuation
raid5_ls
RAID5 left symmetric.
Rotating parity 0 with data restart
raid5_rs
RAID5 right symmetric.
Rotating parity N with data restart
raid6 Same as raid6_zr
raid6_zr
RAID6 zero restart
Rotating parity zero (left-to-right) with data restart
raid6_nr
RAID6 N restart
Rotating parity N (left-to-right) with data restart
raid6_nc
RAID6 N continue
Rotating parity N (left-to-right) with data continuation
raid10 (Red Hat Enterprise Linux 6.4 and later
Striped mirrors
Striping of mirror sets

For most users, specifying one of the five available primary types (raid1, raid4, raid5, raid6, raid10) should be sufficient. For more information on the different algorithms used by RAID 5/6, refer to chapter four of the Common RAID Disk Data Format Specification at http://www.snia.org/sites/default/files/SNIA_DDF_Technical_Position_v2.0.pdf.
When you create a RAID logical volume, LVM creates a metadata subvolume that is one extent in size for every data or parity subvolume in the array. For example, creating a 2-way RAID1 array results in two metadata subvolumes (lv_rmeta_0 and lv_rmeta_1) and two data subvolumes (lv_rimage_0 and lv_rimage_1). Similarly, creating a 3-way stripe (plus 1 implicit parity device) RAID4 results in 4 metadata subvolumes (lv_rmeta_0, lv_rmeta_1, lv_rmeta_2, and lv_rmeta_3) and 4 data subvolumes (lv_rimage_0, lv_rimage_1, lv_rimage_2, and lv_rimage_3).
The following command creates a 2-way RAID1 array named my_lv in the volume group my_vg that is 1G in size.
# lvcreate --type raid1 -m 1 -L 1G -n my_lv my_vg
You can create RAID1 arrays with different numbers of copies according to the value you specify for the -m argument. Although the -m argument is the same argument used to specify the number of copies for the previous mirror implementation, in this case you override the default segment type mirror by explicitly setting the segment type as raid1. Similarly, you specify the number of stripes for a RAID 4/5/6 logical volume with the familiar -i argument, overriding the default segment type with the desired RAID type. You can also specify the stripe size with the -I argument.

Note

You can set the default mirror segment type to raid1 by changing mirror_segtype_default in the lvm.conf file.
The following command creates a RAID5 array (3 stripes + 1 implicit parity drive) named my_lv in the volume group my_vg that is 1G in size. Note that you specify the number of stripes just as you do for an LVM striped volume; the correct number of parity drives is added automatically.
# lvcreate --type raid5 -i 3 -L 1G -n my_lv my_vg
The following command creates a RAID6 array (3 stripes + 2 implicit parity drives) named my_lv in the volume group my_vg that is 1G in size.
# lvcreate --type raid6 -i 3 -L 1G -n my_lv my_vg
After you have created a RAID logical volume with LVM, you can activate, change, remove, display, and use the volume just as you would any other LVM logical volume.
When you create RAID10 logical volumes, the background I/O required to initialize the logical volumes with a sync operation can crowd out other I/O operations to LVM devices, such as updates to volume group metadata, particularly when you are creating many RAID logical volumes. This can cause the other LVM operations to slow down.
As of Red Hat Enterprise Linux 6.5, you can control the rate at which a RAID logical volume is initialized by implementing recovery throttling. You control the rate at which sync operations are performed by setting the minimum and maximum I/O rate for those operations with the --minrecoveryrate and --maxrecoveryrate options of the lvcreate command. You specify these options as follows.
  • --maxrecoveryrate Rate[bBsSkKmMgG]
    Sets the maximum recovery rate for a RAID logical volume so that it will not crowd out nominal I/O operations. The Rate is specified as an amount per second for each device in the array. If no suffix is given, then kiB/sec/device is assumed. Setting the recovery rate to 0 means it will be unbounded.
  • --minrecoveryrate Rate[bBsSkKmMgG]
    Sets the minimum recovery rate for a RAID logical volume to ensure that I/O for sync operations achieves a minimum throughput, even when heavy nominal I/O is present. The Rate is specified as an amount per second for each device in the array. If no suffix is given, then kiB/sec/device is assumed.
The following command creates a 2-way RAID10 array with 3 stripes that is 10G is size with a maximum recovery rate of 128 kiB/sec/device. The array is named my_lv and is in the volume group my_vg.
lvcreate --type raid10 -i 2 -m 1 -L 10G --maxrecoveryrate 128 -n my_lv my_vg
You can also specify minimum and maximum recovery rates for a RAID scrubbing operation. For information on RAID scrubbing, see Section 4.4.15.10, “Scrubbing a RAID Logical Volume”.