Monday, January 23, 2012

LVM In Linux

Practical steps to "Extend/Reduce" LVM Partition in RedHat/CentOS 5x & Fedora Linux upto version 12 only.

############To Extend LVM Partition:############
Note: No need to unmount the partition.

In my case, I want to extend my LVM partition to 200MB on LV0, the command is,
Command:1
lvextend -L 200M /dev/vg0/lv0

Command:2
fsck /dev/vg0/lv0

Command:3
e2fsck -f /dev/vg0/lv0

Command:4 (Used to get output of the said extended partition)
lvdisplay /dev/vg0/lv0
df -kh

############To Reduce LVM Partition:############

Note: Unmount the said partition first before reducing.

In my case, I have mounted "lv0" on "google0" directory, the command would be,

Command:1
umount /google0 /dev/vg0/lv0

Command:2
e2fsck -f /dev/vg0/lv0

Command:3
resize2fs /dev/vg0/lv0 50M (I have reduced LVM Partition size from 150 MB to 50 MB)

Command:4
lvreduce /dev/vg0/lv0 -L 50M

Command:5
mount /dev/vg0/lv0 /google0/ (Remount LV0 on google0 directory)

Command:6 (Used to get output of the said reduced partition)
lvdisplay /dev/vg0/lv0
df -kh