менеджер логических томов для объединения нескольких физических дисковых устройств в логический модуль (LVM RAID)
RAID TAKEOVER
RAID takeover is converting a RAID LV from one RAID level to
another, e.g. raid5 to raid6. Changing the RAID level is
usually done to increase or decrease resilience to device
failures or to restripe LVs. This is done using lvconvert and
specifying the new RAID level as the LV type:
lvconvert --type
RaidLevel LV [PVs]
The most common and recommended RAID takeover conversions are:
linear
to raid1
Linear is a single image of LV data, and converting it to
raid1 adds a mirror image which is a direct copy of the
original linear image.
striped
/raid0
to raid4
/5
/6
Adding parity devices to a striped volume results in
raid4/5/6.
Unnatural conversions that are not recommended include converting
between striped and non-striped types. This is because file
systems often optimize I/O patterns based on device striping
values. If those values change, it can decrease performance.
Converting to a higher RAID level requires allocating new SubLVs
to hold RAID metadata, and new SubLVs to hold parity blocks for
LV data. Converting to a lower RAID level removes the SubLVs
that are no longer needed.
Conversion often requires full synchronization of the RAID LV
(see Synchronization
). Converting to RAID1 requires copying all
LV data blocks to N new images on new devices. Converting to a
parity RAID level requires reading all LV data blocks,
calculating parity, and writing the new parity blocks.
Synchronization can take a long time depending on the throughpout
of the devices used and the size of the RaidLV. It can degrade
performance. Rate controls also apply to conversion; see
--minrecoveryrate
and --maxrecoveryrate
.
Warning: though it is possible to create striped
LVs with up to
128 stripes, a maximum of 64 stripes can be converted to raid0
,
63 to raid4/5
and 62 to raid6
because of the added parity SubLVs.
A striped
LV with a maximum of 32 stripes can be converted to
raid10
.
The following takeover conversions are currently possible:
• between striped and raid0.
• between linear and raid1.
• between mirror and raid1.
• between raid1 with two images and raid4/5.
• between striped/raid0 and raid4.
• between striped/raid0 and raid5.
• between striped/raid0 and raid6.
• between raid4 and raid5.
• between raid4/raid5 and raid6.
• between striped/raid0 and raid10.
• between striped and raid4.
Indirect conversions
Converting from one raid level to another may require multiple
steps, converting first to intermediate raid levels.
linear
to raid6
To convert an LV from linear to raid6:
1. convert to raid1 with two images
2. convert to raid5 (internally raid5_ls) with two images
3. convert to raid5 with three or more stripes (reshape)
4. convert to raid6 (internally raid6_ls_6)
5. convert to raid6 (internally raid6_zr, reshape)
The commands to perform the steps above are:
1. lvconvert --type raid1 --mirrors 1 LV
2. lvconvert --type raid5 LV
3. lvconvert --stripes 3 LV
4. lvconvert --type raid6 LV
5. lvconvert --type raid6 LV
The final conversion from raid6_ls_6 to raid6_zr is done to avoid
the potential write/recovery performance reduction in raid6_ls_6
because of the dedicated parity device. raid6_zr rotates data
and parity blocks to avoid this.
linear
to striped
To convert an LV from linear to striped:
1. convert to raid1 with two images
2. convert to raid5_n
3. convert to raid5_n with five 128k stripes (reshape)
4. convert raid5_n to striped
The commands to perform the steps above are:
1. lvconvert --type raid1 --mirrors 1 LV
2. lvconvert --type raid5_n LV
3. lvconvert --stripes 5 --stripesize 128k LV
4. lvconvert --type striped LV
The raid5_n type in step 2 is used because it has dedicated
parity SubLVs at the end, and can be converted to striped
directly. The stripe size is increased in step 3 to add extra
space for the conversion process. This step grows the LV size by
a factor of five. After conversion, this extra space can be
reduced (or used to grow the file system using the LV).
Reversing these steps will convert a striped LV to linear.
raid6
to striped
To convert an LV from raid6_nr to striped:
1. convert to raid6_n_6
2. convert to striped
The commands to perform the steps above are:
1. lvconvert --type raid6_n_6 LV
2. lvconvert --type striped LV
Examples
Converting an LV from linear
to raid1
.
# lvs -a -o name,segtype,size vg
LV Type LSize
lv linear 300.00g
# lvconvert --type raid1 --mirrors 1 vg/lv
# lvs -a -o name,segtype,size vg
LV Type LSize
lv raid1 300.00g
[lv_rimage_0] linear 300.00g
[lv_rimage_1] linear 300.00g
[lv_rmeta_0] linear 3.00m
[lv_rmeta_1] linear 3.00m
Converting an LV from mirror
to raid1
.
# lvs -a -o name,segtype,size vg
LV Type LSize
lv mirror 100.00g
[lv_mimage_0] linear 100.00g
[lv_mimage_1] linear 100.00g
[lv_mlog] linear 3.00m
# lvconvert --type raid1 vg/lv
# lvs -a -o name,segtype,size vg
LV Type LSize
lv raid1 100.00g
[lv_rimage_0] linear 100.00g
[lv_rimage_1] linear 100.00g
[lv_rmeta_0] linear 3.00m
[lv_rmeta_1] linear 3.00m
Converting an LV from linear
to raid1
(with 3 images).
# lvconvert --type raid1 --mirrors 2 vg/lv
Converting an LV from striped
(with 4 stripes) to raid6_n_6
.
# lvcreate --stripes 4 -L64M -n lv vg
# lvconvert --type raid6 vg/lv
# lvs -a -o lv_name,segtype,sync_percent,data_copies
LV Type Cpy%Sync #Cpy
lv raid6_n_6 100.00 3
[lv_rimage_0] linear
[lv_rimage_1] linear
[lv_rimage_2] linear
[lv_rimage_3] linear
[lv_rimage_4] linear
[lv_rimage_5] linear
[lv_rmeta_0] linear
[lv_rmeta_1] linear
[lv_rmeta_2] linear
[lv_rmeta_3] linear
[lv_rmeta_4] linear
[lv_rmeta_5] linear
This convert begins by allocating MetaLVs (rmeta_#) for each of
the existing stripe devices. It then creates 2 additional
MetaLV/DataLV pairs (rmeta_#/rimage_#) for dedicated raid6
parity.
If rotating data/parity is required, such as with raid6_nr, it
must be done by reshaping (see below).