LVM Notes

From Urandom
Jump to: navigation, search

Contents

What LUN is connected to a Volume Group

vgdisplay -v VolGroup03 #You will get the mpath
multipath -l #Will found out /dev/sdXX
sg_map -i | grep sdXX #Will get /dev/sgXX
sg_scan -i | grep sgXX #WIN

Check que size in iostat

iostat -xk 5 2

Mount a DD copy of a device

kpartx -av backup.dd
ls -l /dev/mapper/
pvdisplay
vgchange -a y
mount /dev/mapper/vg00-lv_opt /mnt/

Deactivate LVM Volume group

vgchange -a n my_volume_group

Create LVM

fdisk a partition to type 8e (Linux LVM)

pvcreate /dev/hdXN - inizialize a LVM
vgcreate my_volume_group /dev/hdXN /dev/hdYM - create a volume group
lvcreate -L1008 -nlv_root vg01
lvcreate -n NAME -l 100%FREE vg0 -create one with maximum size

Add disk to volume group

echo "- - -" > /sys/class/scsi_host/HOST#/scan
#OR scan all hosts at once.
cd /sys/class/scsi_host/ && ls -1 | while read line; do echo "- - -" > /sys/class/scsi_host/$line/scan; done

pvcreate /dev/sdb
vgextend vg00 /dev/sdb


Extend/Resize swap space

swapoff -v /dev/VolGroup00/LogVol02

lvm lvresize /dev/VolGroup00/LogVol02 -L +256M
or
lvextend -L 512M /dev/VolGroup00/LogVol02

mkswap /dev/VolGroup00/LogVol02
swapon -va

Extend/Resize partition

lvresize /dev/vg00/lv_opt -l +100%FREE
resize2fs /dev/vg00/lv_opt

Reduce partition

Reduce the filesystem (ext4)

resize2fs -p /dev/mapper/vg00_root 2G

Reduce the underlying LVM

lvreduce -L 2G  /dev/mapper/vg00_root 
Personal tools