This guide describes basic to advanced use of Linux LVM.
#Create Physical Volume
fdisk /dev/sdb1
Create 1 partition with the type as Linux LVM
pvcreate /dev/sdb1
#Create Volume Group
vgcreate VolGroup /dev/sdb1
#Create Logical Volume
lvcreate -L60g VolGroup -n first_Vol
#Add disk to Volume Group
vgextend VolGroup disk
#Resizing a filesystem
Unmount
lvresize -L 500M /dev/vg/vol
e2fsck -f /dev/vg/vol
resize2fs /dev/vg_redhat/lv_home 80G
#Resizing a volume
Unmount
e2fsck -f /dev/vg/vol
resize2fs /dev/vg_redhat/lv_home 80G
e2fsck -f /dev/vg/vol
lvreduce -L 80G /dev/vg_redhat/lv_home
e2fsck -f /dev/vg/vol
#Create a Snapshot
lvcreate -L592M -s -n snapname Volume
#Removing a snapshot
lvremove Volume
#Rescan Volume Groups
vgchange -a y
#Mirror a Volume
lvcreate -L 80G -n Mirror_name -m 1 VolGroup
#Mirror existing Volume
lvconvert -m1 VolGroup/Volume –mirrorlog core
#Removing the mirror
lvconvert -m0 VolGroup/VOlume mirrordevice_to_remove
#Splitting the mirror
lvconvert –splitmirrors 2 –name copy vg/lv
or….
lvconvert –splitmirrors 2 –name copy vg/lv /dev/sd[ce]1
#Simulate a disk failure
dd if=/dev/zero of=/dev/sda1 count=10
vgreduce –removemissing –force vg
#Remove missing Drives:
#vgreduce –removemissing –force /dev/data
#Check to see which drives belong to which volume
#lvs -a -o +devices
#Recover from snapshot volume failure
#cat /etc/lvm/archive/*.vg | grep -i uuid
#vgchange -a y –partial
#pvcreate –uuid “FmGRh3-zhok-iVI8-7qTD-S5BI-MAEN-NYM5Sk” –restorefile #/etc/lvm/archive/VG_00050.vg /dev/sdh1
#vgcfgrestore VG
#vgchange -a y
#lvscan