You are here
Home > Redhat > Logical volume management (LVM)

Logical volume management (LVM)

fdisk -l ( To list partition)

create two Parition in unallocated space (sda5&sda6)
——————————————
fdisk /dev/sda

n – to create partition

t – partion type (8e for lvm)

w – save

partprobe ( to update to kernel)

To create physical Volume
——————————–
pvcreate /dev/sda5 /dev/sda6

pvdisplay ( to check status of physical volume)

To create volume group
—————————
vgcreate /dev/vg0 /dev/sda5 /dev/sda6 ( vg0 – device name for volume group)

vgdisplay ( to check status of volume group)

To create logical volume
—————————–
lvcreate -L + 200M -n lvm /dev/vg0 (L for size of lvm and n for logical volume label and lvm is name for logical volume)

lvdisplay (status of lvm)

vgdisplay ( status of volume group)

mkfs.ext3 /dev/vg0/lvm (format logical volume created under /dev/vg0)

mkdir /logical (creating to mount lvm partition under /logical folder)

mount /dev/vg0/lvm /logical

vi /etc/fstab

/dev/vg0/lvm /logical ext3 defaults 0 0

save fstab

mount -a ( update all mounted partition to kernel )
or
mount -o remount /logical ( update mounted logical partition only to kernel)

df -lh ( check mounted status)
or
mount ( check mounted status)

To extend lvm
—————–
lvextend -L +200M /dev/vg0/lvm ( increase lvm size)

lvdisplay

resize2fs /dev/vg0/lvm (to resize the old lvm size to new extended size)

lvdisplay

vgdisplay

To reduce lvm
—————–
umount /logical

resize2fs /dev/vg0/lvm 200M ( to compress the lvm partition data to 200Mb size)

e2fsck -f /dev/vg0/lvm ( to run chkdisk)

resize2fs /dev/vg0/lvm 200M ( to compress the lvm partition data to 200Mb size)

lvreduce -L 200M /dev/vg0/lvm ( to reduce the lvm partition size)

mount /dev/vg0/lvm /logical
or
mount /logical

lvdisplay
vgdisplay
df -h
 

Leave a Reply

9 − 3 =

Top