LinuxCommandLibrary

lvm

Manage logical volumes

TLDR

Start the Logical Volume Manager interactive shell

$ sudo lvm
copy

Initialize a drive or partition to be used as a physical volume
$ sudo lvm pvcreate [/dev/sdXY]
copy

Display information about physical volumes
$ sudo lvm pvdisplay
copy

Create a volume group called vg1 from the physical volume on /dev/sdXY
$ sudo lvm vgcreate [vg1] [/dev/sdXY]
copy

Display information about volume groups
$ sudo lvm vgdisplay
copy

Create a logical volume with size 10G from volume group vg1
$ sudo lvm lvcreate -L [10G] [vg1]
copy

Display information about logical volumes
$ sudo lvm lvdisplay
copy

Display help for a specific command
$ lvm help [command]
copy

SYNOPSIS

lvm command [options] [arguments]

PARAMETERS

pvcreate
    Creates LVM physical volumes.

vgcreate
    Creates LVM volume groups.

lvcreate
    Creates LVM logical volumes.

pvdisplay
    Displays properties of LVM physical volumes.

vgdisplay
    Displays properties of LVM volume groups.

lvdisplay
    Displays properties of LVM logical volumes.

pvremove
    Removes LVM physical volumes.

vgremove
    Removes LVM volume groups.

lvremove
    Removes LVM logical volumes.

lvextend
    Extends the size of a logical volume.

lvreduce
    Reduces the size of a logical volume.

--version
    Displays the LVM version.

-h, --help
    Displays help message.

DESCRIPTION

The Linux Logical Volume Manager (LVM) provides a method of allocating disk space that is more flexible than traditional partitioning. Instead of allocating fixed-size partitions to filesystems, LVM allows you to create logical volumes from volume groups. Volume groups are created from one or more physical volumes, which can be whole disks, partitions, or even other logical volumes.

LVM enables you to resize, move, create snapshots of, and otherwise manage logical volumes without disrupting the data stored on them. This is particularly useful for managing large databases, filesystems that are likely to grow, and systems where flexibility in storage allocation is critical. LVM offers features such as online resizing, snapshotting for backups, striping for performance, and mirroring for redundancy.

CAVEATS

LVM requires careful planning and execution. Incorrect operations can lead to data loss. Always back up important data before making changes to LVM configurations.

ACTIVATION

Logical volumes must be activated before they can be mounted and used. The lvchange command is used to activate and deactivate logical volumes. Upon system boot, logical volumes are typically automatically activated if configured to do so.

HISTORY

LVM was initially developed to address the limitations of traditional partitioning schemes, providing more flexible and dynamic storage management. It has undergone several iterations, improving performance, stability, and feature set. LVM is now a standard component of most Linux distributions and is widely used in enterprise environments.

SEE ALSO

pvscan(8), vgscan(8), lvscan(8), mount(8), fdisk(8)

Copied to clipboard