Wednesday, April 20, 2011

LVM (linear and striped mapping)

Its important to know what lvm version are you working on, there are lots of feature/options depends on this.

lvm version
LVM version: 2.02.56(1)-RHEL5 (2010-04-22)
Library version: 1.02.39-RHEL5 (2010-04-22)
Driver version: 4.11.5

Few common commands:
lvmdiskscan - scan for all devices visible to LVM2
lvs - Display information about logical volumes
pvs - Display information about physical volumes
vgs - Display information about volume groups


lvcreate -n stripedlv -i 2 -I 64 mygroup -L 20M
-i we tell LVM how many Physical Volumes it should use to scatter on
-I we can specify the granulation in kilobytes

How to check if lvm is linear or striped?
lvdisplay -m
A Physical Volume, containing Physical Extents:

+-----[ Physical Volume ]------+
| PE | PE | PE | PE | PE | PE |
+------------------------------+

A Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:

+------[ Volume Group ]-----------------+
| +--[PV]--------+ +--[PV]---------+ |
| | PE | PE | PE | | PE | PE | PE | |
| +--------------+ +---------------+ |
+---------------------------------------+

We now further expand this:

+------[ Volume Group ]-----------------+
| +--[PV]--------+ +--[PV]---------+ |
| | PE | PE | PE | | PE | PE | PE | |
| +--+---+---+---+ +-+----+----+---+ |
| | | | +-----/ | | |
| | | | | | | |
| +-+---+---+-+ +----+----+--+ |
| | Logical | | Logical | |
| | Volume | | Volume | |
| | | | | |
| | /home | | /var | |
| +-----------+ +------------+ |
+---------------------------------------+
This shows us two filesystems, spanning two disks. The /home filesystem contains 4 Physical Extents, the /var filesystem 2.

look for type -> linear or striped