Logical Volume Management provides a great deal of flexibility allowing you to dynamically re-allocate blocks of space to different file systems. Traditional volume manage relies upon strict partition boundaries separating and containerizing each mount point. Logical Volume Management in linux takes control of the whole drive carving it out into equal chunks called physical extents (PE). Each PE is addressed by it’s logical extent (LE) address. Groups of LE’s are grouped together to form logical volumes (LV) that are used to mount as file systems. Then LV’s are grouped into volume groups (VG) for management purposes.
Creating a Physical Volume
Use the pvcreate command to create a PV. To create a PV on an empty disk (/dev/sda) use this command:
You can also setup PV’s on current empty partitions. Use fdisk to change to system ID of the partition to hex 8e then use the pvcreate command on the partition. Any data on that partition will be lost.
Create a Volume Group
Once you have one or more PV’s you can create a LV. LV’s can cross multiple partitions or disks. To create the initial VG called bob use the following command:
vgcreate bob /dev/sda1 /dev/sda3
If you would like to add space to bob use the following command:
vgextend bob /dev/hda1
If you want to reduce space you can use the following command:
vgreduce bob /dev/hda1
Creating the logical volume
Now that you have one or more PV’s grouped together in VG’s your ready for a logical volume and file systems. In order to create a mountable file system it would be best to know the size of each PE. This will allow you to define the correct size for each mount point. You display a lot of information on vg’s with the following command:
Then you can create an LV of the correct size with the lvcreate command:
lvcreate -l num_of_PEs bob -n name_of_LV
This will create a LV inside the location /dev/bob/name_of_LV. Then you can use standard disk tools on the logical volume to lay down a file system. If you want to extend the size of the LV you use the lvextend command for example to add 150Mb’s:
lvextend -L150M /dev/bob/name_of_LV
© 2009 – 2010, Joseph Griffiths. All rights reserved.