Este contenido no está disponible en el idioma seleccionado.
4.8. Customized Reporting for LVM
LVM provides a wide range of configuration and command line options to produce customized reports and to filter the report's output. For a full description of LVM reporting features and capabilities, see the
lvmreport(7) man page.
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.
As of the Red Hat Enterprise Linux 7.3 release, you can report information about physical volumes, volume groups, logical volumes, physical volume segments, and logical volume segments all at once with the
lvm fullreport command. For information on this command and its capabilities, see the lvm-fullreport(8) man page.
As of the Red Hat Enterprise Linux 7.3 release, LVM supports log reports, which contain a log of operations, messages, and per-object status with complete object identification collected during LVM command execution. For an example of an LVM log report, see Section 4.8.6, “Command Log Reporting (Red Hat Enterprise Linux 7.3 and later)”. For further information about the LVM log report. see the
lvmreport(7) man page.
The following sections provide summary information on the use of the
pvs, lvs, and vgs commands to customize a report:
- Section 4.8.1, “Format Control”, which provides a summary of command arguments you can use to control the format of the report.
- Section 4.8.2, “Object Display Fields”, which provides a list of the fields you can display for each LVM object.
- Section 4.8.3, “Sorting LVM Reports”, which provides a summary of command arguments you can use to sort the generated report.
- Section 4.8.4, “Specifying Units”, which provides instructions for specifying the units of the report output.
- Section 4.8.5, “JSON Format Output (Red Hat Enterprise Linux 7.3 and later)”, which provides an example that specifies JSON format output (Red Hat Enterprise Linux 7.3 and later).
- Section 4.8.6, “Command Log Reporting (Red Hat Enterprise Linux 7.3 and later)”, which provides an example of a command log.
4.8.1. Format Control Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
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
-oargument. For example, the following output is the default display for thepvscommand (which displays information about physical volumes).Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following command displays only the physical volume name and size.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Adding the
-vargument to a command includes some extra fields. For example, thepvs -vcommand will display theDevSizeandPV UUIDfields in addition to the default fields.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
--noheadingsargument suppresses the headings line. This can be useful for writing scripts.The following example uses the--noheadingsargument in combination with thepv_nameargument, which will generate a list of all physical volumes.pvs --noheadings -o pv_name
# pvs --noheadings -o pv_name /dev/sdb1 /dev/sdc1 /dev/sdd1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
--separator separatorargument uses separator to separate each field.The following example separates the default output fields of thepvscommand with an equals sign (=).Copy to Clipboard Copied! Toggle word wrap Toggle overflow To keep the fields aligned when using theseparatorargument, use theseparatorargument in conjunction with the--alignedargument.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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.
4.8.2. Object Display Fields Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
This section provides a series of tables that list the information you can display about the LVM objects with the
pvs, vgs, and lvs commands.
For convenience, a field name prefix can be dropped if it matches the default for the command. For example, with the
pvs command, name means pv_name, but with the vgs command, name is interpreted as vg_name.
Executing the following command is the equivalent of executing
pvs -o pv_free.
Note
The number of characters in the attribute fields in
pvs, vgs, and lvs output may increase in later releases. The existing character fields will not change position, but new fields may be added to the end. You should take this into account when writing scripts that search for particular attribute characters, searching for the character based on its relative position to the beginning of the field, but not for its relative position to the end of the field. For example, to search for the character p in the ninth bit of the lv_attr field, you could search for the string "^/........p/", but you should not search for the string "/*p$/".
The pvs Command Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Table 4.3, “The pvs Command Display Fields” lists the display arguments of the
pvs command, along with the field name as it appears in the header display and a description of the field.
| Argument | Header | Description |
|---|---|---|
dev_size | DevSize | The size of the underlying device on which the physical volume was created |
pe_start | 1st PE | Offset to the start of the first physical extent in the underlying device |
pv_attr | Attr | Status of the physical volume: (a)llocatable or e(x)ported. |
pv_fmt | Fmt | The metadata format of the physical volume (lvm2 or lvm1) |
pv_free | PFree | The free space remaining on the physical volume |
pv_name | PV | The physical volume name |
pv_pe_alloc_count | Alloc | Number of used physical extents |
pv_pe_count | PE | Number of physical extents |
pvseg_size | SSize | The segment size of the physical volume |
pvseg_start | Start | The starting physical extent of the physical volume segment |
pv_size | PSize | The size of the physical volume |
pv_tags | PV Tags | LVM tags attached to the physical volume |
pv_used | Used | The amount of space currently used on the physical volume |
pv_uuid | PV UUID | The UUID of the physical volume |
The
pvs command displays the following fields by default: pv_name, vg_name, pv_fmt, pv_attr, pv_size, pv_free. The display is sorted by pv_name.
Using the
-v argument with the pvs command adds the following fields to the default display: dev_size, pv_uuid.
You can use the
--segments argument of the pvs command to display information about each physical volume segment. A segment is a group of extents. A segment view can be useful if you want to see whether your logical volume is fragmented.
The
pvs --segments command displays the following fields by default: pv_name, vg_name, pv_fmt, pv_attr, pv_size, pv_free, pvseg_start, pvseg_size. The display is sorted by pv_name and pvseg_size within the physical volume.
You can use the
pvs -a command to see devices detected by LVM that have not been initialized as LVM physical volumes.
The vgs Command Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Table 4.4, “vgs Display Fields” lists the display arguments of the
vgs command, along with the field name as it appears in the header display and a description of the field.
| Argument | Header | Description |
|---|---|---|
lv_count | #LV | The number of logical volumes the volume group contains |
max_lv | MaxLV | The maximum number of logical volumes allowed in the volume group (0 if unlimited) |
max_pv | MaxPV | The maximum number of physical volumes allowed in the volume group (0 if unlimited) |
pv_count | #PV | The number of physical volumes that define the volume group |
snap_count | #SN | The number of snapshots the volume group contains |
vg_attr | Attr | Status of the volume group: (w)riteable, (r)eadonly, resi(z)eable, e(x)ported, (p)artial and (c)lustered. |
vg_extent_count | #Ext | The number of physical extents in the volume group |
vg_extent_size | Ext | The size of the physical extents in the volume group |
vg_fmt | Fmt | The metadata format of the volume group (lvm2 or lvm1) |
vg_free | VFree | Size of the free space remaining in the volume group |
vg_free_count | Free | Number of free physical extents in the volume group |
vg_name | VG | The volume group name |
vg_seqno | Seq | Number representing the revision of the volume group |
vg_size | VSize | The size of the volume group |
vg_sysid | SYS ID | LVM1 System ID |
vg_tags | VG Tags | LVM tags attached to the volume group |
vg_uuid | VG UUID | The UUID of the volume group |
The
vgs command displays the following fields by default: vg_name, pv_count, lv_count, snap_count, vg_attr, vg_size, vg_free. The display is sorted by vg_name.
vgs
# vgs
VG #PV #LV #SN Attr VSize VFree
new_vg 3 1 1 wz--n- 51.42G 51.36G
Using the
-v argument with the vgs command adds the following fields to the default display: vg_extent_size, vg_uuid.
The lvs Command Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Table 4.5, “lvs Display Fields” lists the display arguments of the
lvs command, along with the field name as it appears in the header display and a description of the field.
Note
In later releases of Red Hat Enterprise Linux, the output of the
lvs command may differ, with additional fields in the output. The order of the fields, however, will remain the same and any additional fields will appear at the end of the display.
| Argument | Header | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chunk | Unit size in a snapshot volume | ||||||||||
copy_percent | Copy% | The synchronization percentage of a mirrored logical volume; also used when physical extents are being moved with the pv_move command | ||||||||||
devices | Devices | The underlying devices that make up the logical volume: the physical volumes, logical volumes, and start physical extents and logical extents | ||||||||||
lv_ancestors | Ancestors | (Red Hat Enterprise Linux 7.2 and later) For thin pool snapshots, the ancestors of the logical volume | ||||||||||
lv_descendants | Descendants | (Red Hat Enterprise Linux 7.2 and later) For thin pool snapshots, the descendants of the logical volume | ||||||||||
lv_attr | Attr | The status of the logical volume. The logical volume attribute bits are as follows:
| ||||||||||
lv_kernel_major | KMaj | Actual major device number of the logical volume (-1 if inactive) | ||||||||||
lv_kernel_minor | KMIN | Actual minor device number of the logical volume (-1 if inactive) | ||||||||||
lv_major | Maj | The persistent major device number of the logical volume (-1 if not specified) | ||||||||||
lv_minor | Min | The persistent minor device number of the logical volume (-1 if not specified) | ||||||||||
lv_name | LV | The name of the logical volume | ||||||||||
lv_size | LSize | The size of the logical volume | ||||||||||
lv_tags | LV Tags | LVM tags attached to the logical volume | ||||||||||
lv_uuid | LV UUID | The UUID of the logical volume. | ||||||||||
mirror_log | Log | Device on which the mirror log resides | ||||||||||
modules | Modules | Corresponding kernel device-mapper target necessary to use this logical volume | ||||||||||
move_pv | Move | Source physical volume of a temporary logical volume created with the pvmove command | ||||||||||
origin | Origin | The origin device of a snapshot volume | ||||||||||
| Region | The unit size of a mirrored logical volume | ||||||||||
seg_count | #Seg | The number of segments in the logical volume | ||||||||||
seg_size | SSize | The size of the segments in the logical volume | ||||||||||
seg_start | Start | Offset of the segment in the logical volume | ||||||||||
seg_tags | Seg Tags | LVM tags attached to the segments of the logical volume | ||||||||||
segtype | Type | The segment type of a logical volume (for example: mirror, striped, linear) | ||||||||||
snap_percent | Snap% | Current percentage of a snapshot volume that is in use | ||||||||||
stripes | #Str | Number of stripes or mirrors in a logical volume | ||||||||||
| Stripe | Unit size of the stripe in a striped logical volume |
The
lvs command displays the following fields by default: lv_name, vg_name, lv_attr, lv_size, origin, snap_percent, move_pv, mirror_log, copy_percent, convert_lv. The default display is sorted by vg_name and lv_name within the volume group.
lvs
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvol0 new_vg owi-a- 52.00M
newvgsnap1 new_vg swi-a- 8.00M lvol0 0.20
Using the
-v argument with the lvs command adds the following fields to the default display: seg_count, lv_major, lv_minor, lv_kernel_major, lv_kernel_minor, lv_uuid.
You can use the
--segments argument of the lvs command to display information with default columns that emphasize the segment information. When you use the segments argument, the seg prefix is optional. The lvs --segments command displays the following fields by default: lv_name, vg_name, lv_attr, stripes, segtype, seg_size. The default display is sorted by vg_name, lv_name within the volume group, and seg_start within the logical volume. If the logical volumes were fragmented, the output from this command would show that.
Using the
-v argument with the lvs --segments command adds the following fields to the default display: seg_start, stripesize, chunksize.
The following example shows the default output of the
lvs command on a system with one logical volume configured, followed by the default output of the lvs command with the segments argument specified.
4.8.3. Sorting LVM Reports Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Normally the entire output of the
lvs, vgs, or pvs command has to be generated and stored internally before it can be sorted and columns aligned correctly. You can specify the --unbuffered argument to display unsorted output as soon as it is generated.
To specify an alternative ordered list of columns to sort on, use the
-O argument of any of the reporting commands. It is not necessary to include these fields within the output itself.
The following example shows the output of the
pvs command that displays the physical volume name, size, and free space.
The following example shows the same output, sorted by the free space field.
The following example shows that you do not need to display the field on which you are sorting.
To display a reverse sort, precede a field you specify after the
-O argument with the - character.
4.8.4. Specifying Units Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To specify the unit for the LVM report display, use the
--units argument of the report command. You can specify (b)ytes, (k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes, (e)xabytes, (p)etabytes, and (h)uman-readable. The default display is human-readable. You can override the default by setting the units parameter in the global section of the lvm.conf file.
The following example specifies the output of the
pvs command in megabytes rather than the default gigabytes.
By default, units are displayed in powers of 2 (multiples of 1024). You can specify that units be displayed in multiples of 1000 by capitalizing the unit specification (B, K, M, G, T, H).
The following command displays the output as a multiple of 1024, the default behavior.
The following command displays the output as a multiple of 1000.
You can also specify (s)ectors (defined as 512 bytes) or custom units.
The following example displays the output of the
pvs command as a number of sectors.
The following example displays the output of the
pvs command in units of 4 MB.
4.8.5. JSON Format Output (Red Hat Enterprise Linux 7.3 and later) Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
As of Red Hat Enterprise Linux 7.3, you can use the
--reportformat option of the LVM display commands to display the output in JSON format.
The following example shows the output of the
lvs in standard default format.
The following command shows the output of the same LVM configuration when you specify JSON format.
You can also set the report format as a configuration option in the
/etc/lvm/lvm.conf file, using the output_format setting. The --reportformat setting of the command line, however, takes precedence over this setting.
4.8.6. Command Log Reporting (Red Hat Enterprise Linux 7.3 and later) Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
As of Red Hat Enterprise Linux 7.3, both report-oriented and processing-oriented LVM commands can report the command log if this is enabled with the
log/report_command_log configuration setting. You can determine the set of fields to display and to sort by for this report.
The following examples configures LVM to generate a complete log report for LVM commands. In this example, you can see that both logical volumes
lvol0 and lvol1 were successfully processed, as was the volume group VG that contains the volumes.
For further information on configuring LVM reports and command logs, see the
lvmreport man page.