The document discusses advanced topics in Logical Volume Management (LVM) including data protection using mirroring, data migration between physical volumes, using LVM with multipath devices, and accessing LVM in a rescue environment. It provides examples of commands to build mirrored and striped logical volumes, recover from failed drives, migrate data between disks, and configure LVM to work with multipath devices.
2. Agenda
● Logical Volume Manager Overview
● Data Protection
● Data migration
● LVM & Multipath Devices
● Using LVM in a Rescue environment
LVM Advanced topics
3. LVM Overview
● Eliminates the need for partitions to manage disks
● Adds flexibility that partitions do not provide
● Provides RAID 0 and RAID 1 like functionality
● Logical Volumes can be created small and grown as
needed much easier then a partition
● As useful on a laptop with one hard drive as it is on
servers with hundreds of LUNs
LVM Advanced topics
6. Data Protection with LVM
● Data is protected via LE mirroring.
● Mirrored logical volumes can span more then
two storage devices in a RAID 0 + 1 like fashion.
● Does not provide parity data protection and can
not be used to create RAID 3 - 6 logical volumes.
LVM Advanced topics
7. Building A Mirrored Logical Volume
[wills@localhost ~]$ sudo pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created
[wills@localhost ~]$ sudo pvcreate /dev/vdc
Physical volume "/dev/vdc" successfully created
[wills@localhost ~]$ sudo vgcreate VolGroup02
/dev/vdb /dev/vdc
Volume group "VolGroup02" successfully created
[wills@localhost ~]$ sudo lvcreate m1 L 508M
corelog nosync n LogVol00 VolGroup02
WARNING: New mirror won't be synchronised. Don't
read what you didn't write!
Logical volume "LogVol00" created
LVM Advanced topics
8. Building A Mirrored Logical
Volume Continued
[wills@localhost ~]$ sudo lvdisplay
/dev/VolGroup02/LogVol00
Logical volume
LV Name /dev/VolGroup02/LogVol00
VG Name VolGroup02
LV UUID S7PeP1QN2YVtxF0qjYzk7jcq6n8rJjvF
LV Write Access read/write
LV Status available
# open 0
LV Size 508.00 MiB
Current LE 127
Mirrored volumes 2
Segments 1
Allocation inherit
Read ahead sectors auto
currently set to 256
Block device 253:2
LVM Advanced topics
9. Recover Failed Drive
Mirrored LV
[wills@localhost ~]$ sudo lvdisplay v
/dev/VolGroup02/LogVol00
Using logical volume(s) on command line
Wiping cache of LVMcapable devices
Couldn't find device with uuid pKWuz6XidZaqAS6GQG9OrB
cyQWzOnRgp.
There are 1 physical volumes missing.
Logical volume
LV Name /dev/VolGroup02/LogVol00
VG Name VolGroup02
LV UUID DtrdmhqT5MxjtNmD0tmcM2j3I7CCBJUA
LV Write Access read/write
LV Status available
Snip
LVM Advanced topics
10. Recover Failed Drive
Mirrored LV Continued
[wills@localhost ~]$ sudo pvcreate uuid pKWuz6XidZ
aqAS6GQG9OrBcyQWzOnRgp restorefile
/etc/lvm/archive/VolGroup02_00037.vg /dev/vde
Couldn't find device with uuid pKWuz6XidZaqAS6GQG9OrB
cyQWzOnRgp.
Physical volume "/dev/vde" successfully created
[wills@localhost ~]$ sudo vgcfgrestore f
/etc/lvm/archive/VolGroup02_00037.vg
VolGroup02 Restored volume group VolGroup02
[wills@localhost ~]$ sudo vgchange a y VolGroup02
1 logical volume(s) in volume group "VolGroup02" now
active
LVM Advanced topics
11. Building A Stripped &
Mirrored Logical
[wills@localhost ~]$ sudo pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created
[wills@localhost ~]$ sudo pvcreate /dev/vdd
Physical volume "/dev/vdd" successfully created
[wills@localhost ~]$ sudo pvcreate /dev/vdc
Physical volume "/dev/vdc" successfully created
[wills@localhost ~]$ sudo pvcreate /dev/vdf
Physical volume "/dev/vdf" successfully created
[wills@localhost ~]$ sudo vgcreate VolGroup02 /dev/vdb
/dev/vdd /dev/vdf /dev/vde
Volume group "VolGroup02" successfully created
[wills@localhost ~]$ sudo lvcreate i2 I128 m 1
corelog L900M n LogVol00 VolGroup02
Rounding size (225 extents) up to stripe boundary size
(226 extents)
Logical volume "LogVol00" created
LVM Advanced topics
17. LVM & Multipath Devices
● LVM scans the attached drives for its logical
volumes at boot and when any LVM command is
run.
● LVM must be configured so that it only finds each PV once!
● LVM will not start a Volume Group if it finds
duplicate matches for a PV UUID.
● Limits on LVM's ability to find duplicate paths are
implemented with a Filter in lvm.conf
filter = [ "a/mpath.*/", "r/.*/" ]
LVM Advanced topics
18. LVM in the Rescue Environment
● The many commands that comprise the LVM userland are all
softlinks to /sbin/lvm
● Use the same commands you are used to using but prefix the
command with "lvm "
● You may need to locate and active VGs and LVs
○ lvm vgscan
○ lvm vgchange -a y
● Any configuration settings that were needed in lvm.conf, i.e.
"filter", will need to be passed on the command line with --config.
○ lvm vgscan --config 'devices{ filter = [ "a/mpath.*/",
"r/.*/" ] }'
LVM Advanced topics