Tuesday 7 July 2009

LVM Logical volume management

Physical Volumes
Physical volumes are effectively the same as partitions on the physical hard disk.  To create a physical volume out of the partition:
# pvcreate /dev/sdb3
Volume Groups
Groups of one or more physical volumes that contain volume groups. This allows a logical volume to be spread over several partitions etc.  vgdisplay shows the current volume groups and vgextend is used to add another physical volume to a volume group
# vgdisplay
# vgextend <volume group name> <physical volume name>
Logical Volumes
The "end user" partitions.
# lvdisplay
# lvextend -L23GB /dev/VolGroup00/LogVol00 <— expand logical volume to 23GB
Resize partition on logical volumeIf the logical volume has been increased then to expand the file system to use the whole logical volume run the following command:
# ext2resize /dev/VolGroup00/LogVol00
Activate LVM under live CD
A good walkthrough to activating LVM under Knoppix (hard to change if using the partition) can be found here: http://linuxwave.blogspot.com/2007/11/mounting-lvm-disk-using-ubuntu-livecd.html. In short:
Boot using the live cd.
# apt-get install lvm2 (already installed in knoppix 5.1.1)
# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free]
Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]

# vgscan
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2

# vgchange -a y
2 logical volume(s) in volume group "VolGroup00" now active

# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit

# mount /dev/VolGroup00/LogVol00 /mnt

1 comment:

  1. Thanks for the great post on LVM! LVM is pretty complicated so it's good to have a simple guide I can reference when stuff breaks! Keep up all the good Linux posts!

    -Ben www.portforwardpodcast.com

    ReplyDelete