User Tools

Site Tools


lvm

This is an old revision of the document!


LVM

LVM you can increase / decrease size without any issue.
But it is important you do it in proper steps.

Steps to create LVM from drive

pvcreate /dev/xvdf1
pvdisplay /dev/xvdf1
vgcreate -s 16M vg0 /dev/xvdf1
vgdisplay /dev/xvdf
vgdisplay vg0
lvcreate -n lv-vol001 vg0
lvcreate --help
lvcreate -A n -L 24.5G -n lv-vol001 vg0
mkfs.ext3 /dev/vg0/lv-vol001

Add drive to LVM

fdisk /dev/xvdk ## Comment "Specify Type 8e by option t"
mkfs.ext3 /dev/xvdk1 
pvcreate /dev/xvdk1 
vgextend vg0 /dev/xvdk1
lvextend -L 300G /dev/vg0/lv-vol001 
lvextend -L+99.91G /dev/vg0/lv-vol001
OR
lvextend -l +100%FREE /dev/vg0/lv-vol001
resize2fs /dev/vg0/lv-vol001

Reducing Size

umount /home
e2fsck -y /dev/mapper/VolGroup00-LogVol00
resize2fs -f /dev/mapper/VolGroup00-LogVol00 1536M
lvreduce -L-512M /dev/mapper/VolGroup00-LogVol00 
mount /home

Increasing Size

umount /opt/
e2fsck -y /dev/mapper/VolGroup00-LogVol02
lvextend -L+512M /dev/mapper/VolGroup00-LogVol02
resize2fs /dev/mapper/VolGroup00-LogVol02
mount /opt

Worked Example on Live System

| history
fdisk -l
fdisk /dev/sda ## Comment "Specify Type 8e by option t"
mkfs.ext3 /dev/sda1
vgextend VolGroup00 /dev/sda1
lvdisplay
vgdisplay 
lvextend -l+1599 /dev/VolGroup00/LogVol00
df -kh
vgdisplay
lvdisplay 
resize2fs /dev/VolGroup00/LogVol00 
df -kh
lvm.1471366048.txt.gz · Last modified: 2016/08/16 16:47 by k2patel