LVM Logical Volume Display (lvs) - Command Line Tool Guide

Learn how to use the lvs command to display LVM logical volume information. Explore options for detailed output, units, sorting, filtering, and JSON format.

LVM Logical Volume Display (lvs)

The lvs command is a powerful utility in the Linux Logical Volume Manager (LVM) suite, designed to display information about logical volumes. Understanding how to use lvs effectively is crucial for managing storage efficiently on LVM-enabled systems. This guide provides a comprehensive overview of its common uses and options.

Basic Logical Volume Information

To view basic information about all logical volumes on your system, simply run the command without any arguments. This provides a concise overview of each logical volume, including its name, volume group, and size.

# Display basic information about all logical volumes
lvs

Detailed and Formatted Output

For more in-depth details, including attributes and segment information, you can use the verbose flag. Additionally, you can specify units for sizes (e.g., gigabytes) and sort the output by various criteria like volume size for easier analysis.

# Display logical volume information with more details (use long listing format)
lvs -v

# Display logical volume information with units (e.g., KB, MB, GB)
lvs --units g

# Show all logical volumes sorted by size
lvs --sort lv_size

Filtering and Specific Displays

lvs allows you to filter the output to show only specific logical volumes, such as those belonging to a particular volume group. You can also customize the displayed columns to show only the information you need, like the volume size.

# Filter to display only logical volumes that belong to a specific volume group
lvs my_volume_group

# Display logical volumes in a columnar format, specifically showing only the volume size
lvs --options lv_size

Advanced Options and Output Formats

For scripting and automated processing, lvs offers options to suppress headings and output data in JSON format. You can also select specific logical volumes based on their attributes, such as their active status.

# Suppress headings in the output for easier parsing
lvs --noheadings

# Display only active logical volumes
lvs --select 'lv_active==active'

# Show logical volumes and their metadata in JSON format
lvs --reportformat json

External Resources