LVM (Logical volume manager) is a software component, which aggregates disks and/or partitions as a physical partition (PV) in a volume group (VG) and allows to create on the fly logical volumes (Partitions) (LV) and to resize them on the fly.  Linux, Aix, OS2, Solarix, FreeBSD and other support LVM. Windows2000 and above has a similar concept but is not compatible with LVM. Linux distros like Debian, Mandrake, Mint, Ubuntu, Redhat, Slackware und openSuSE allow to install Linux on LVM managed disks but unfortunately per default there will be no LVM be used. Following pages describe in detail the capabilities and benefits of LVM and why every Linux user should also use LVM on his system.

Logical parts of LVM and their relationships

 
LVM uses following terms:
 
PV: Physical volume - a physical disk or partition of a disk
PE: Physical extent partition - a storage area of a PV
LV: Logical volume - a collection of multiple PEs. Corresponds to a partition in an non LVM managed system
LE: Logical extent - a logical storage area of a LV which refers to a physical storage area in a PV
VG: Volume group - a collection of multiple PVs and the LVs created in the PV
  
Following picture depicts all of the major LVM parts
 
lvm.jpg
   
PVs /dev/sda1, /dev/sda2 etc have physical extents (PE). Multiple PVs are combined in a volumegroup (VG) dataVG. This volumengroup dataVG has logical volumes (LV) /dev/LV1 and /dev/LV2 configured. They use logical extents (LE), which point to physical extents in the assiciated PVs. The PEs can point to PE on different PVs (/dev/LV2 PEs auf PV /dev/sda1, /dev/sdb1 and /dev/sdb2). These logical volumes have different filesystems (FS) ext3 and  ext4 and are mounted to the operating system with mountpoint (MP) /home and /.
 
A move to the LVM world is quite easy if you remeber following two relations:
  • A LV in the LVM world is just a partition in the old world
  • A VG in the LVM world is just a collection of multiple disks
 
Advantages of LVM
  1. If you have a partition/LV which is to small you can increase the LV size on the fly. A size decrease is also possible. So you can easily increase the size of a partion (old terminlogy)  and decrease and don't have to use a repartitioning tool to repartition your disks.
  2. If a VG is too small and you can't create a new partition/LV just add another PV (additional disk) to the VG and you have now additional space for your LV. So you can increase the size of a partition which already spans the whole disk (old terminology)  just by adding another disk to the VG and increase the LV (partition in old terminolgy).
  3. If you need a new partion/LV to install another operating system create a new LV on the fly, format it and mount it. If you don't need the partition/LV any more just delete the LV again and free the used space.
  4. If you want to save a partition/LV for a test and in order to be able to revert to a previous partition content level you can use snapshots for LVs. That's not a complete copy of an existing partition/LV. The snapshot collects only the changes from the partition/LV. Keep in mind the snapshot disappears if the snapshot is not able to get all the changes any more. To be on the safe side you should create the snapshot partition with the same sisze like the original partition.
 
Disadvantages of LVM
  1. If you want to use the full features of LVM you have to use the LVM console commands. All standard activities can be done with a LVM GUI.
  2. Windows can't be installed on LVM LVs. If you want to have a dual boot environment with Windows you have to create a dedicated old fashion partition which is not managed by LVM.
  3. If you combine a lot of disks in one VG the probability of a failure of the VG increase by every disk you add. If one disk fails than usually the whole VG fails. You have to setup a RAID  together with LVM in order to get rid of this advantage.
  4. You shoudln't use a whole disk as a PV (e.g. /dev/sda) . (In contrast a partition which spans the whole disk e.g. /dev/sda1), because other operating systems like Windows may not detect the LVM and view the disk as empty. That way it's possible to overwrite the LVM PV by accident.

Graphical interfaces for LVM
The graphical interfaces provide the most important and heavily used LVM administration tasks like to create and erase a PV/VG/LV and to increase and decrease a LV. If you want to use the whole power of LVM you have to use the console commands.
  1. openSuSE: YAST includes  a LVM editor
  2. Debian, Ubuntu, Redhat, Mint, Fedora, Centos: system-config-lvm
 
Summary
A system administrator will use LVM for sure. LVM allows to provide in a flexible way to create partitions on the fly and to modify the size of them. A standard Linux home user will also profit from LVM. Today the disks are huge (> 1TB) and LVM is the right tools to dynamically allocate and resize partions of these huge disks. In particular it's useful if you want to install parallel operating systems or if you want to upgrade an existing operating system to the latest level. A lot of time you buy another disk to increase the available disk space for your applications. With LVM it's quite easy to integrate the new disk into a VG and to allocate the new space either in new partition/LV or add additional space to existing partitions/LV. Keep in mind the risk for a VG failure will increase the more disks you combine in one VG. You should have a backup strategy and create backups on external USB disks or NAS boxes. As an alternative you can place LVMs on a RAID system.
A snapshot is also very useful. You can easily create a backup of a partition/LV. If you want to upgrade an operating system that way a backup is created very quick. If the upgrade fails you revert to the snapshot and are done. If everything works fine you use the new snapshot. Keep in mind you have to keep the old LV because the snapshot needs the original LV in order to work properly.
 
List of the most important LVM console commands
 
Create PV:
vcreate /dev/sdb1
 
Cretae VG:
vgcreate neuVG /dev/sda1 /dev/sdb1
 
Extend a VG with a new PV:
vgextend neuVG /dev/sdc1
 
Create a new LV neuLV of 2G in VG neuVG:
lvcreate -L2G -nneuLV neuVG
 
Extend a LV neuLV for 10G:
lvextend -L+10G /dev/neuVG/neuLV
Add comment
Note
eMail is hidden and not visible to the public. It's used to inform you about new comments.