LVM is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.
With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. A physical volume cannot span over more than one drive.
The physical volumes are combined into logical volume groups, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.
Since a physical volume cannot span over multiple drives, to span over more than one drive, create one or more physical volumes per drive.
There several pieces of terminology that you’ll need to understand to make the best use of LVM. The most important things you must know are:
- Physical volumes
These are your physical disks, or disk partitions, such as /dev/hda or /dev/hdb1. These are what you’d be used to using when mounting/unmounting things. Using LVM we can combine multiple physical volumes into volume groups.
- Volume groups
A volume group is comprised of real physical volumes, and is the storage used to create logical volumes which you can create/resize/remove and use. You can consider a volume group as a “virtual partition” which is comprised of an arbitary number of physical volumes.
- Logical volumes
These are the volumes that you’ll ultimately end up mounting upon your system. They can be added, removed, and resized on the fly. Since these are contained in the volume groups they can be bigger than any single physical volume you might have. (ie. 4x5Gb drives can be combined into one 20Gb volume group, and you can then create two 10Gb logical volumes.)
Note : To create LVM the partition type is 8e, or Linux LVM.
Creating a Virtual Volume
# pvcreate /dev/sda /dev/sdb /dev/sdc /dev/sdd
# vgcreate volume_group_one /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
This system will use a single-volume group named volume_group_one
To examine available Physical Volumes, use the pvdisplay command
Use vgdisplay command to see the newly created volgrp VG
Creating Logical Volume
# lvcreate -n logical_volume_one –size 255G volume_group_one
lvdispaly command lists the logical volumes.
At this point we have what appears to our system to be a drive /dev/volume_group_one/ logical_volume_one that we can format, mount, and use.
# mkfs.ext3 /dev/volume_group_one/logical_volume_one
# mkdir /mnt/logical_volume_one
# mount /dev/volume_group_one/logical_volume_one /mnt/logical_volume_one
lvextend -L +100G /dev/volume_group_one/logical_volume_one
The above command adds 100 GB to Logical Volume.
The command above does not actually increase the physical size of volume, to do that you need to:
# resize2fs /dev/volume_group_one/logical_volume_one.
If you require help, contact SupportPRO Server Admin