From Segfault
Jump to navigation Jump to search


Quoting from the LVM2 Resource Page:

LVM2 refers to the userspace toolset that provide logical volume management facilities on linux. 
It is reasonably backwards-compatible with the original LVM toolset.
To use LVM2 you need 3 things: device-mapper in your kernel, the userspace device-mapper support
library (libdevmapper) and the userspace LVM2 tools.


Create a volume group and a logical volume:

pvcreate /dev/sd{y,z}
vgcreate vgtest /dev/sd{y,z}
lvcreate -L 100M -n foobar vgtest

We could have omitted the -L parameter to create the LV using all space left in the VG. Or we can use the --extents parameter to specify percentages:

lvcreate -l 50%FREE -n half vgtest                                                       # Or use 50%VG to allocate half the VG size instead.

Once can also specify RAID levels when creating logical volumes:

lvcreate -l 100%FREE --type raid0 -n lvraid vgtest

Resize logical volumes:

lvresize -L +100M vgtest/half                                                            # Add --resizefs to resize the file system in one go via fsadm

Create a snapshot, e.g. to process backups:

lvcreate -l 20%ORIGIN -s -n foobar_snap vgtest/foobar

Activate all LVs in a VG, which can be necessary if these LVs have not been activated by the boot scripts:

vgchange -ay