Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Red Hat Enterprise Linux 9 Essentials Book now available.

Purchase a copy of Red Hat Enterprise Linux 9 (RHEL 9) Essentials

Red Hat Enterprise Linux 9 Essentials Print and eBook (PDF) editions contain 34 chapters and 298 pages

Preview Book

4.8. Customized Reporting for LVM

You can produce concise and customizable reports of LVM objects with the pvs, lvs, and vgs commands. The reports that these commands generate include one line of output for each object. Each line contains an ordered list of fields of properties related to the object. There are five ways to select the objects to be reported: by physical volume, volume group, logical volume, physical volume segment, and logical volume segment.
The following sections provide:
  • A summary of command arguments you can use to control the format of the generated report.
  • A list of the fields you can select for each LVM object.
  • A summary of command arguments you can use to sort the generated report.
  • Instructions for specifying the units of the report output.

4.8.1. Format Control

Whether you use the pvs, lvs, or vgs command determines the default set of fields displayed and the sort order. You can control the output of these commands with the following arguments:
  • You can change what fields are displayed to something other than the default by using the -o argument. For example, the following output is the default display for the pvs command (which displays information about physical volumes).
    # pvs
      PV         VG     Fmt  Attr PSize  PFree
      /dev/sdb1  new_vg lvm2 a-   17.14G 17.14G
      /dev/sdc1  new_vg lvm2 a-   17.14G 17.09G
      /dev/sdd1  new_vg lvm2 a-   17.14G 17.14G
    
    The following command displays only the physical volume name and size.
    # pvs -o pv_name,pv_size
      PV         PSize
      /dev/sdb1  17.14G
      /dev/sdc1  17.14G
      /dev/sdd1  17.14G
    
  • You can append a field to the output with the plus sign (+), which is used in combination with the -o argument.
    The following example displays the UUID of the physical volume in addition to the default fields.
    # pvs -o +pv_uuid
      PV         VG     Fmt  Attr PSize  PFree  PV UUID
      /dev/sdb1  new_vg lvm2 a-   17.14G 17.14G onFF2w-1fLC-ughJ-D9eB-M7iv-6XqA-dqGeXY
      /dev/sdc1  new_vg lvm2 a-   17.14G 17.09G Joqlch-yWSj-kuEn-IdwM-01S9-X08M-mcpsVe
      /dev/sdd1  new_vg lvm2 a-   17.14G 17.14G yvfvZK-Cf31-j75k-dECm-0RZ3-0dGW-UqkCS
    
  • Adding the -v argument to a command includes some extra fields. For example, the pvs -v command will display the DevSize and PV UUID fields in addition to the default fields.
    # pvs -v
        Scanning for physical volume names
      PV         VG     Fmt  Attr PSize  PFree  DevSize PV UUID
      /dev/sdb1  new_vg lvm2 a-   17.14G 17.14G  17.14G onFF2w-1fLC-ughJ-D9eB-M7iv-6XqA-dqGeXY
      /dev/sdc1  new_vg lvm2 a-   17.14G 17.09G  17.14G Joqlch-yWSj-kuEn-IdwM-01S9-XO8M-mcpsVe
      /dev/sdd1  new_vg lvm2 a-   17.14G 17.14G  17.14G yvfvZK-Cf31-j75k-dECm-0RZ3-0dGW-tUqkCS
    
  • The --noheadings argument suppresses the headings line. This can be useful for writing scripts.
    The following example uses the --noheadings argument in combination with the pv_name argument, which will generate a list of all physical volumes.
    # pvs --noheadings -o pv_name
      /dev/sdb1
      /dev/sdc1
      /dev/sdd1
    
  • The --separator separator argument uses separator to separate each field.
    The following example separates the default output fields of the pvs command with an equals sign (=).
    # pvs --separator =
      PV=VG=Fmt=Attr=PSize=PFree
      /dev/sdb1=new_vg=lvm2=a-=17.14G=17.14G
      /dev/sdc1=new_vg=lvm2=a-=17.14G=17.09G
      /dev/sdd1=new_vg=lvm2=a-=17.14G=17.14G
    
    To keep the fields aligned when using the separator argument, use the separator argument in conjunction with the --aligned argument.
    # pvs --separator = --aligned
      PV        =VG    =Fmt =Attr=PSize =PFree
      /dev/sdb1 =new_vg=lvm2=a-  =17.14G=17.14G
      /dev/sdc1 =new_vg=lvm2=a-  =17.14G=17.09G
      /dev/sdd1 =new_vg=lvm2=a-  =17.14G=17.14G
    
You can use the -P argument of the lvs or vgs command to display information about a failed volume that would otherwise not appear in the output. For information on the output this argument yields, see Section 6.2, “Displaying Information on Failed Devices”.
For a full listing of display arguments, see the pvs(8), vgs(8) and lvs(8) man pages.
Volume group fields can be mixed with either physical volume (and physical volume segment) fields or with logical volume (and logical volume segment) fields, but physical volume and logical volume fields cannot be mixed. For example, the following command will display one line of output for each physical volume.
# vgs -o +pv_name
  VG     #PV #LV #SN Attr   VSize  VFree  PV
  new_vg   3   1   0 wz--n- 51.42G 51.37G /dev/sdc1
  new_vg   3   1   0 wz--n- 51.42G 51.37G /dev/sdd1
  new_vg   3   1   0 wz--n- 51.42G 51.37G /dev/sdb1

 
 
  Published under the terms of the Creative Commons License Design by Interspire