lvm Command Examples in Linux

The lvm command is used to manage physical volumes, volume groups, and logical volumes in a Linux Logical Volume Manager (LVM) system. The lvm command launches an interactive shell, allowing you to perform various LVM management operations.

Physical volumes (PVs) represent the actual storage devices, such as hard drives or solid-state drives, in a LVM system. Volume groups (VGs) are collections of physical volumes that are used to create logical volumes (LVs). LVs are virtual partitions on a VG that can be resized, moved, and otherwise managed without affecting the underlying physical storage.

With the lvm shell, you can perform a wide range of LVM management tasks, including:

  • Creating and deleting physical volumes
  • Creating and deleting volume groups
  • Creating and deleting logical volumes
  • Extending and reducing the size of logical volumes
  • Moving logical volumes between physical volumes
  • Displaying information about physical volumes, volume groups, and logical volumes And more.

The lvm shell provides a convenient and powerful way to manage LVM storage in Linux, allowing you to dynamically allocate, manage, and reconfigure storage as needed.

lvm Command Examples

1. Start the Logical Volume Manager interactive shell:

# lvm

2. List the Logical Volume Manager commands:

# lvm help

3. Initialize a drive or partition to be used as a physical volume:

# lvm pvcreate /dev/sdXY

4. Display information about physical volumes:

# lvm pvdisplay

5. Create a volume group called vg1 from the physical volume on `/dev/sdXY`:

# lvm vgcreate vg1 /dev/sdXY

6. Display information about volume groups:

# lvm vgdisplay

7. Create a logical volume with size 10G from volume group vg1:

# lvm lvcreate -L 10G vg1

8. Display information about logical volumes:

# lvm lvdisplay
Related Post