Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

Appendix C. LVM Selection Criteria

As of Red Hat Enterprise Linux release 7.1, many LVM reporting commands accept the -S or --select option to define selection criteria for those commands. As of Red Hat Enterprise Linux release 7.2, many processing commands support selection criteria as well. These two categories of commands for which you can define selection criteria are defined as follows:
  • Reporting commands — Display only the lines that satisfy the selection criteria. Examples of reporting commands for which you can define selection criteria include pvs, vgs, lvs, pvdisplay, vgdisplay, lvdisplay, lvm devtypes, and dmsetup info -c.
    Specifying the -o selected option in addition to the -S option displays all rows and adds a "selected" column that shows 1 if the row matches the selection criteria and 0 if it does not.
  • Processing commands — Process only the items that satisfy the selection criteria. Examples of processing commands for which you can define selection criteria include pvchange, vgchange, lvchange, vgimport, vgexport, vgremove, and lvremove.
Selection criteria are a set of statements that use comparison operators to define the valid values for particular fields to display or process. The selected fields are, in turn, combined by logical and grouping operators.
When specifying which fields to display using selection criteria, there is no requirement for the field which is in the selection criteria to be displayed. The selection criteria can contain one set of fields while the output can contain a different set of fields.
  • For a listing of available fields for the various LVM components, see Section C.3, “Selection Criteria Fields”.
  • For a listing of allowed operators, see Section C.2, “Selection Criteria Operators”. The operators are also provided on the lvm(8) man page.
  • You can also see full sets of fields and possible operators by specifying the help (or ?) keyword for the -S/--select option of a reporting commands. For example, the following command displays the fields and possible operators for the lvs command.
    # lvs -S help
For the Red Hat Enterprise Linux 7.2 release, you can specify time values as selection criteria for fields with a field type of time. For information on specifying time values, see Section C.4, “Specifying Time Values”.

C.1. Selection Criteria Field Types

The fields you specify for selection criteria are of a particular type. The help output for each field display the field type enclosed in brackets. The following help output examples show the output indicating the field types string, string_list, number, percent, size and time.
lv_name             - Name. LVs created for internal use are enclosed in brackets.[string]
lv_role             - LV role. [string list]
raid_mismatch_count - For RAID, number of mismatches found or repaired. [number]
copy_percent        - For RAID, mirrors and pvmove, current percentage in-sync. [percent]
lv_size             - Size of LV in current units. [size]
lv_time             - Creation time of the LV, if known [time]
Table C.1, “Selection Criteria Field Types” describes the selection criteria field types

Table C.1. Selection Criteria Field Types

Field TypeDescription
number Non-negative integer value.
size Floating point value with units, 'm' unit used by default if not specified.
percent Non-negative integer with or without % suffix.
string Characters quoted by ' or " or unquoted.
string list Strings enclosed by [ ] or { } and elements delimited by either "all items must match" or "at least one item must match" operator.
The values you specify for a field can be the following:
  • Concrete values of the field type
  • Regular expressions that include any fields of the string field type, such as "+~" operator.
  • Reserved values; for example -1, unknown, undefined, undef are all keywords to denote an undefined numeric value.
  • Defined synonyms for the field values, which can be used in selection criteria for values just as for their original values. For a listing of defined synonyms for field values, see Table C.14, “Selection Criteria Synonyms”.