This instruction and syntax are relevant for Red Hat 6, the latest commands could be found here.
Inital configuration is following: VG vgtest consist from 4x2g disks with one striped LV over all disks.
# pvs PV VG Fmt Attr PSize PFree /dev/sdb rootvg lvm2 a-- 19.97g 6.75g /dev/sdc vgtest lvm2 a-- 2.00g 508.00m /dev/sdd vgtest lvm2 a-- 2.00g 508.00m /dev/sde vgtest lvm2 a-- 2.00g 508.00m /dev/sdf vgtest lvm2 a-- 2.00g 508.00m /dev/sdg lvm2 --- 16.00g 16.00g # lvdisplay -m /dev/vgtest/data --- Logical volume --- LV Path /dev/vgtest/data LV Name data VG Name vgtest LV UUID 5a9j6n-lIM8-LnFQ-i646-Q9W6-4cH9-1s3Qih LV Write Access read/write LV Creation host, time tmplt6-64, 2015-07-20 08:50:03 +0000 LV Status available # open 0 LV Size 6.00 GiB Current LE 1536 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 1024 Block device 253:7 --- Segments --- Logical extents 0 to 1535: Type striped Stripes 4 Stripe size 64.00 KiB Stripe 0: Physical volume /dev/sdc Physical extents 0 to 383 Stripe 1: Physical volume /dev/sdd Physical extents 0 to 383 Stripe 2: Physical volume /dev/sdf Physical extents 0 to 383 Stripe 3: Physical volume /dev/sde Physical extents 0 to 383
The task is to migrate it online to other single disk as non stiped logical volume. Add destination disk (PV) to VG:
# pvcreate --dataalignment 4k /dev/sdg # vgextend vgtest /dev/sdg Volume group "vgtest" successfully extended
Add mirror chain to striped LV on new PV:
# lvconvert -b -m1 /dev/vgtest/data /dev/sdg Logical volume data converted. # lvs -a -o +devices | grep -v rootvg LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices data vgtest mwi-aom--- 6.00g data_mlog 93.29 data_mimage_0(0),data_mimage_1(0) [data_mimage_0] vgtest Iwi-aom--- 6.00g /dev/sdc(0),/dev/sdd(0),/dev/sdf(0),/dev/sde(0) [data_mimage_1] vgtest Iwi-aom--- 6.00g /dev/sdg(0) [data_mlog] vgtest lwi-aom--- 4.00m /dev/sdg(1536)
Repeat command until Cpy%Sync becomes 100 (mirror in sync), then break mirror, removing stripped chain:
# lvconvert -m0 /dev/vgtest/data /dev/sdc /dev/sdd /dev/sdf /dev/sde Logical volume data converted. # lvs -a -o +devices | grep -v rootvg LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices data vgtest -wi-ao---- 6.00g # vgreduce vgtest /dev/sdc /dev/sdd /dev/sde /dev/sdf Removed "/dev/sdc" from volume group "vgtest" Removed "/dev/sdd" from volume group "vgtest" Removed "/dev/sde" from volume group "vgtest" Removed "/dev/sdf" from volume group "vgtest"
Finally remove physical devices from VG, then unconfigure SCSI device and unmap source LUNs.
Now we have an opposite situation, we have a plain LV that want convert to striped. Add desired amount of LUNs accoring to stripes amount, and rescan SCSI bus. Create PV and add them to VG:
# pvs PV VG Fmt Attr PSize PFree /dev/sdb rootvg lvm2 a-- 19.97g 6.75g /dev/sdc lvm2 --- 4.00g 4.00g /dev/sdd lvm2 --- 4.00g 4.00g /dev/sdg vgtest lvm2 a-- 16.00g 10.00g # vgextend vgtest /dev/sdc /dev/sdd Volume group "vgtest" successfully extended
Create mirror chain for existing LV with desired parameters:
# lvconvert -m1 --stripes 2 /dev/vgtest/data /dev/sdc /dev/sdd Using default stripesize 64.00 KiB vgtest/data: Converted: 0.0% vgtest/data: Converted: 30.2% vgtest/data: Converted: 59.4% vgtest/data: Converted: 100.0% # lvs -a -o +devices | grep -v rootvg LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices data vgtest mwi-aom--- 6.00g data_mlog 100.00 data_mimage_0(0),data_mimage_1(0) [data_mimage_0] vgtest iwi-aom--- 6.00g /dev/sdg(0) [data_mimage_1] vgtest iwi-aom--- 6.00g /dev/sdc(0),/dev/sdd(0) [data_mlog] vgtest lwi-aom--- 4.00m /dev/sdd(768) # pvdisplay -m /dev/sdd --- Physical volume --- PV Name /dev/sdd VG Name vgtest PV Size 4.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 1023 Free PE 254 Allocated PE 769 PV UUID 1ucJ4r-lc9N-BcHU-jOjU-PWg0-h3xI-q8szeP --- Physical Segments --- Physical extent 0 to 767: Logical volume /dev/vgtest/data_mimage_1 Logical extents 0 to 1535 Physical extent 768 to 768: Logical volume /dev/vgtest/data_mlog Logical extents 0 to 0 Physical extent 769 to 1022: FREE
Break mirror removing desired chain:
# lvconvert -m0 /dev/vgtest/data /dev/sdg Logical volume data converted. # lvs -a -o +devices | grep -v rootvg LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices data vgtest -wi-ao---- 6.00g /dev/sdc(0),/dev/sdd(0)
Remove original PV from VG, unconfigure SCSI device, then unmap LUN.