lvcreate

From RaySoft

lvcreate creates a new logical volume in a volume group by allocating logical extents from the free physical extent pool of that volume group. If there are not enough free physical extents then the volume group can be extended with other physical volumes or by reducing existing logical volumes of this volume group in size.[1]

Documentation

Syntax

lvcreate [PARAMETER ...] NAME|PATH

Parameters

-l NUMBER, --extents NUMBER
Gives the NUMBER of logical extents to allocate for the new logical volume. This can also be expressed as a percentage of the total space in the Volume Group with the suffix %VG or of the remaining free space with the suffix %FREE.
-L SIZE, --size SIZE
Gives the SIZE to allocate for the new logical volume.
A size suffix is optional (Default unit is megabytes):
  • K for kilobytes
  • M for megabytes
  • G for gigabytes
  • T for terabytes
-n NAME, --name NAME
The NAME for the new logical volume.
-s, --snapshot
Create a snapshot logical volume (or snapshot) for an existing, so called original logical volume (or origin). Snapshots provide a 'frozen image' of the contents of the origin while the origin can still be updated. They enable consistent backups and online recovery of removed/overwritten data/files. The snapshot does not need the same amount of storage the origin has. In a typical scenario, 15-20% might be enough. In case the snapshot runs out of storage, use lvextend to grow it. Shrinking a snapshot is supported by lvreduce as well. Run lvdisplay on the snapshot in order to check how much data is allocated to it.

Examples

Create a new 40GB logical volume on the volume group /dev/vg_neon_01
vgdisplay '/dev/vg_neon_01'
lvcreate --size '40G' --name 'lv_export' '/dev/vg_neon_01'
lvdisplay '/dev/vg_neon_01/lv_export'
mkfs.ext3 '/dev/vg_neon_01/lv_export'
Create a snapshot from the logical volume /dev/vg_neon_01/lv_export
lvcreate --snapshot --size '500M' --name 'lv_export_snapshot' '/dev/vg_neon_01/lv_export'
mount '/dev/vg_neon_01/lv_export_snapshot' '/mnt'

Do something with /mnt...

umount '/mnt'
lvremove '/dev/vg_neon_01/lv_export_snapshot'

References

  1. man 8 'lvcreate'