Logical Volume Manager

_Article in progress_

Introduction

LVM means Logical Volume Manager. It allows the partitionning of disk space at a high abstraction level, whatever the hardware ressource used. LVM offers a high flexibility level for resizing the volume. Logical volume can be spread on different hardware storage. There is no more limitation like it could be have with primary and extended partition. LVM can be used on physical hardware, virtual storage (virtualization) and RAID system.

I will first give some definition of objects used by LVM. Then, individual command for each object will be explained. Finally a suite of command will be listed in order to set a LVM system.


Definition

Abbreviation

Definition

Comment

PV

Physical Volume

It is the lowest level of abstraction, all the hardware available

GV

Group Volume

It is a grouping of several hardware, a cluster of PV

LV

Logical Volume

It is a partition of the GV used by the system on which the FS will be mount

FS

File System

It is the file system of the LV (ext3, ext4, …)


Linux package

In order to manage LVM, the LVM2 package should be installed:

sudo apt-get install lvm2

This package provides all commands described in the next section.

After installation, you have access to LVM commands: ![LVM commands](/assets/computer_science/linux/logicvolmanag/lvm2command_1.png)


Command

All volumes previously listed (PV, GV and LV) have its own command to manage them. These commands are used to create, resize, delete and displayed informations. They are prefixed by pv for physical volumes, gv for group volumes and lv for logical volumes.

Command for physical volume

pvdisplay is used to display all physical volumes. The result should be something like the below picture. It depends of course of your environment.

link error !!

Fig. 53 Physical volume display

pvs -o+pv_used (Fig. 54) is used to know who use the physical volumes.

link error !!

Fig. 54 Physical volume display used

pvcreate /dev/sda is used to create a physical volume.

_note: a partition (ie /dev/sdb2) could be used like a physical volume. It must be labeled 8E (type LVM) with the fdsik commmand. The command is then pvcreate /dev/sdb2._

Sum up of physical volume commands

Command

Description

pvcreate

create a physical volume

pvresize

change the size of a physical volume

pvdisplay

display information of a physical volume

pvremove

delete a physical volume

pvmove

move the content of a PV to another PV

pvchange

change metadata of a physical volume

pvscan

detect physical volumes

Command for group volume

The same principle is used to work with group volume. Note that all group command are not stricly the same than for physical group.

vgdisplay is used to display all group volumes. The result should be something like the below picture. It depends of course of your environment.

link error !!

Fig. 55 Group volume display

Sum up of group volume commands

Command

Description

vgcreate

create a group volume

vgdisplay or vgs

display information of a group volume

vgremove

delete a group volume

vgck

check metadata consistency of a group volume

vgscan

detect group volumes

vgextend

add a PV to a GV

vgrename

rename a group volume

vgreduce

remove an unused GV from a PV