Table of Contents

Logical Volume Manager

Partition type: 8e00 (Linux LVM)

see also:

Benefits

LVM mainly offers the following benefits which a classical MBR or GPT partition layout cannot offer due to its nature of having to reside in a partition table with physical sector boundaries.

increased abstraction, flexibility, and control. Logical volumes can have meaningful names like databases or root-backup. Volumes can be resized dynamically as space requirements change and migrated between physical devices within the pool on a running system or exported easily. LVM also offers advanced features like snapshotting, striping, and mirroring.1

Commands

ready drive for LVM pvcreate
create a new VG vgcreate NAME PVNAME
show logical volumes lvdisplay
enlarge LOGICALVOL by 10GB lvresize --size +10G LOGICALVOL
create logical volume with 10GB in vg0 lvcreate -L 10G vg0 -n NAME

Terminology

PV Physical Volume (e.g. a disk; can contain a LV)
LV Logical Volume
LVM Logical Volume Manager
LE Logical Extent
PE Physical Extent
VG Volume Group (grouping of one or more PVs)
VGDA Volume Group Descriptor Area

Striping ("RAID-0")

LVM: convert linear to striped

This requires temporarily having 2x the size of your LVM volume. You need to create a mirror of your data, with the new leg of the mirror striped over the target disks, then drop the old leg of the mirror that was not striped.

If you want to stripe over ALL of your disks (including the one that was already used), you also need to specify --alloc anywhere otherwise the mirror code will refuse to use any disk twice.

# convert to a mirror (-m1), with new leg striped over 4 disks: /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde
# --mirrorlog core - use in-memory status during the conversion
# --interval 1: print status every second
lvconvert --interval 1 -m1 $myvg/$mylv --mirrorlog core --type mirror --stripes 4 /dev/sd{b,c,d,e}
# drop the old leg, /dev/sda
lvconvert --interval 1 -m0 $myvg/$mylv  /dev/sda

RAID-1

only one disk

mdadm --create /dev/md0 --verbose --level=1 --raid-devices=2 missing /dev/sdb1

Articles