Sunday, January 2, 2011

Logical Volume Manager Setup and Configuration

Here is a short summary of LVM configuration and setup.

Check to make sure you have LVM2:
vgscan --version

If vgscan complains about missing driver:
modprobe dm_mod

Create physical volumes:
pvcreate /dev/sda1
pvcreate /dev/sda2

Add the physical volumes to a volume group:
vgcreate VolGroup01 /dev/sda1 /dev/sdb1

To create logical volumes out of the volume group:
lvcreate -L <length> -n LogVol01 VolGroup01
ex: lvcreate -L 500M VolGroup01 -n LogVol01
ex: lvcreate -L 20G VolGroup01 -n LogVol01

Create a filesystem
mkfs -t ext3 /dev/VolGroup01/LogVol01

Mount the logical volume
mount /dev/VolGroup01/LogVol01 /mnt/debian

Extending Logical Volume

Unmount the Logical Volume
umount /dev/VolGroup01/LogVol01

If there is free space in the volume group:
lvextend -L +1G /dev/VolGroup01/LogVol01

If the volume group is full then add a disk/partition to it:
vgextend VolGroup01 /dev/sdc1
and then extend the logical volume:
lvextend -L +1G /dev/VolGroup01/LogVol01

Finally, extend the filesystem (any of the below 3 methods)
extendfs -F ext3 /dev/VolGroup01/LogVol01
resize2fs /dev/VolGroup01/LogVol01
resize2fs /dev/VolGroup01/LogVol01 500M

Mount the logical volume

mount /dev/VolGroup01/LogVol01 /mnt/debian

No comments:

Post a Comment