Sunday, February 14, 2010

Linux LVM

Creating A LVM
--------------------
1>pvcreate /dev/hdb5 --pvdisplay /pvs
2>vgdisplay myvg1 /dev/hdb5 --vgs /vgdisplay
3>lvdisplay -L 5000M -n mylv1 myvg1 -- lvs /lvdisplay

Create a partition and mount the Lvm on it
-------------------------------------------

1>Using fdisk create a partitions and then toggle the value to 8e.
2> save and exit fdisk utility .Now run partprobe.It will now show linux lvm in partition section.
To see it using fdisk -l command.
3>Now make a partition (e.g -mkdir -p /lvm )
4> mkfs -t ext3 /myvg1/mylv1
5> mount /myvg1/mylv1 /lvm
6>Now df -h to see the mounted lvm partition and lvdisplay to see the lvm size.

Extending the Logical Volume:
-----------------------------------
lvextend -L +1000M /dev/mylv1/myvg1
resize2fs /dev/mylv1/myvg1

Reducing the Logical Volume:
---------------------------------
umount /lvm
fsck -f /dev/mylv1/myvg1
resize2fs /dev/myvg1/myvg1 1000M
lvreduce /dev/myvg1/mylv1 -L 1000M

Delete cache file
--------------------
rm -rf /etc/lvm/.cache

No comments: