lvdisplay

2024-03-29

Understanding Logical Volumes

Before we look at lvdisplay, let’s briefly recap LVM’s structure. LVM organizes storage into three layers:

  1. Physical Volumes (PVs): These are your physical hard drives or partitions dedicated to LVM.
  2. Volume Groups (VGs): PVs are grouped together to form a VG, providing a larger pool of storage.
  3. Logical Volumes (LVs): LVs are created within VGs and represent the actual storage space you use for filesystems.

The Power of lvdisplay

The lvdisplay command is your window into the LVM world. It displays detailed information about your logical volumes, allowing you to monitor their status, size, and usage. It’s an essential command for troubleshooting and managing your storage.

Basic Usage: Displaying All Logical Volumes

The simplest way to use lvdisplay is to run it without any arguments. This displays information about all LVs in your system:

lvdisplay

This will output something similar to (the exact output will depend on your system):

  LV Name                VG Name               #PP  #LV  Size      Alloc       Origin
  -------------------  ------------------- ---- ---- ----------- ----------- ------------
  mylv                  myvg                 20   1   10.00 GiB  10.00 GiB
  anotherlv             myvg                 10   1    5.00 GiB   5.00 GiB

This shows the Logical Volume Name, Volume Group it belongs to, the number of Physical Extents, number of Logical Volumes (in case of thin provisioning), Size, Allocated space and the origin of the Logical Volume.

Displaying Specific Logical Volumes

To display information about a particular LV, specify its name as an argument:

lvdisplay mylv

This will provide a more detailed report only for mylv.

Using Options for Enhanced Output

lvdisplay offers many options to customize the output:

Example using -c and -m:

lvdisplay -c name,size,major mylv

This will show only the name, size, and major number of mylv.

Handling Errors

If you try to display a non-existent LV, you’ll get an error message:

lvdisplay nonexistantlv
  Error: Logical volume "nonexistantlv" does not exist.

This indicates that the specified LV is not found in your system.

Practical Applications

lvdisplay is useful for:

By mastering lvdisplay, you gain essential skills for effectively managing your Linux storage using LVM. The flexibility and detailed information provided by this command make it a cornerstone of LVM administration.