Physical Volume(PV): Real partition which can be assigned to a pool of resource to create/manage logical volumes
Logical Volume Group(LG): Pool of resources (partitions) which can be used to create/manage Logical volumes
Logical Volumes(LV): Logical Partitions which can be formatted and used just like a normal partition. The difference is that these Logical Partitions can be easily created and resized at will, as long as there is enough resources in the Logical Volume Group (resources pool)

Basic installation instructions:

Install The logical Volume Manager package
apt-get install lvm2
Start the LVM
This will simply load the kernel module ‘dm_mod’ and do some LVM environment checks.
No daemons will be started.
/etc/init.d/lvm2 start
OR probably better for Ubuntu server:
echo 'dm_mod' >> /etc/modules
modprobe dm_mod

Scenario: I have 2 partitions(/dev/sda1 & /dev/sdb1) which I want to assign into a pool of resources that will be used to create flexible logical volumes.


Assign the two Physical Volumes to be used by LVM
pvcreate /dev/sda1

pvcreate /dev/sdb1

Create a Logical Volume Group (data) with both Physical volumes included.
This will be a pool of assigned Physical Volumes which can be used to create/resize etc Logical Volumes
vgcreate data /dev/sda1

vgextend data /dev/sdb1


Create the first logical volume(275 GB)
This volume can be used as a normal partition in system
lvcreate -n data1 -L 275g data

Format the Volume
mkfs.ext4 /dev/data/data1
Create a mountpoint, mount and use the volume like a normal partition
mkdir /DATA1
mount /dev/data/data1 /DATA1

You can take a look at the various commands to control the Logical Volumes
man -k '^pv'
man -k '^vg'
man -k '^lv'

That’s it for the minimum.

Resizing Volumes

Here are some other useful commands for resizing the volumes.
Assuming that we now want to add 20GB of space(total 295GB) to the existing Volume(/dev/data/data1)


Unmount the existing volume
umount /dev/data/data1
Add an extra partition(/dev/sdc1) to the Logical Volumes Group (data)
vgextend data /dev/sdc1
Resize our volume to 295GB. This size doesn’t have to be the full size of all partition members. It can be extended later.
lvextend -L295G /dev/data/data1
Resize the file system to take possession of the new space
resize2fs /dev/data/data1
Remount the Volume
mount /dev/data/data1 /DATA1
Check the new space
df -h /DATA1

Note: There is a good extention to this article which shows how to resize volumes etc. It is in German but can be deducted easily:

%d bloggers like this: