2016-09-12 14:54:37 +03:00
.TH "LVMREPORT" "7" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SH NAME
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
lvmreport \(em LVM reporting and related features
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SH DESCRIPTION
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
LVM uses single reporting infrastructure that sets standard on LVM command's
output and it provides wide range of configuration settings and command line
options to customize report and filter the report's output.
2021-04-15 23:18:05 +03:00
.
.SH USAGE
.
.SS Categorization based on reporting facility
.
2016-09-12 14:54:37 +03:00
Based on functionality, commands which make use of the reporting infrastructure
are divided in two groups:
2021-04-15 23:18:05 +03:00
.
.TP
.B Report-oriented commands
2016-09-12 14:54:37 +03:00
These commands inform about current LVM state and their primary role is to
display this information in compendious way. To make a distinction, we will
2017-03-27 17:45:48 +03:00
name this report as \fBmain report\fP. The set of report-only commands include:
2016-09-12 14:54:37 +03:00
pvs, vgs, lvs, pvdisplay, vgdisplay, lvdisplay, lvm devtypes, lvm fullreport.
2021-04-15 23:18:05 +03:00
For further information about main report, see \fBMain report specifics\fP.
.
.TP
.B Processing-oriented commands
2016-09-12 14:54:37 +03:00
These commands are responsible for changing LVM state and they do not contain
2017-03-27 17:45:48 +03:00
any main report as identified for report-oriented commands, they only perform
some kind of processing. The set of processing-oriented commands includes:
2016-09-12 14:54:37 +03:00
pvcreate, vgcreate, lvcreate, pvchange, vgchange, lvchange, pvremove, vgremove,
lvremove, pvresize, vgextend, vgreduce, lvextend, lvreduce, lvresize, lvrename,
pvscan, vgscan, lvscan, pvmove, vgcfgbackup, vgck, vgconvert, vgexport,
vgimport, vgmknodes.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.RE
If enabled, so called \fBlog report\fP is either displayed solely
2017-03-27 17:45:48 +03:00
(for processing-oriented commands) or in addition to main report
(for report-oriented commands). The log report contains a log of operations,
messages and per-object status with complete object identification collected
2021-04-15 23:18:05 +03:00
during LVM command execution. See \fBLog report specifics\fP for more
2016-09-12 14:54:37 +03:00
information about this report type.
2021-04-15 23:18:05 +03:00
.
.SS Terms
.
2016-09-12 14:54:37 +03:00
When describing reporting functionality and features in this text, we will
use terms \fBrow\fP and \fBcolumn\fP. By row we mean series of values reported
for single entity (for example single PV, VG or LV). Each value from the row
then belongs to a column of certain type. The columns have \fBcolumn headings\fP
which are short descriptions for the columns. The columns are referenced by
\fBcolumn names\fP. Please note that this text is also using term \fBfield\fP
interchangeably with the term \fBcolumn\fP. Most of the time the term columns
is abbreviated as \fBcol\fP in configuration.
2021-04-15 23:18:05 +03:00
.
.SS Common report configuration settings and command line options
.
2016-09-12 14:54:37 +03:00
There are common configuration settings and command line options which apply
to both \fBmain report\fP and \fBlog report\fP. Following lists contain all
of them, separated into groups based on their use.
2021-04-15 23:18:05 +03:00
.
.SS Common configuration settings
.
.ad l
.TP
2016-09-12 14:54:37 +03:00
Changing report output format, composition and other output modifiers:
2021-04-15 23:18:05 +03:00
- global/suffix
.br
- global/units
.br
- report/aligned
.br
- report/binary_values_as_numeric
.br
- report/columns_as_rows
.br
- report/compact_output
.br
- report/compact_output_cols
.br
- report/headings
.br
- report/list_item_separator
.br
- report/mark_hidden_devices
.br
- report/output_format
.br
- report/prefixes
.br
- report/quoted
.br
- report/separator
.br
- report/time_format
.br
- report/two_word_unknown_device
.
.TP
2016-09-12 14:54:37 +03:00
Special settings
2021-04-15 23:18:05 +03:00
- report/buffered
.ad b
.P
2016-09-12 14:54:37 +03:00
This document does not describe these settings in more detail - if you need
detailed information, including values which are accepted for the settings,
2017-03-27 17:45:48 +03:00
please run \fBlvmconfig --type default --withcomments <setting>\fP. There are
2016-09-12 14:54:37 +03:00
more configuration settings in addition to the common set listed above, but
they are specific to either \fBmain report\fP or \fBlog report\fP,
see \fBmain report specifics\fP and \fBlog report specifics\fP for
these settings. Besides configuring reports globally by using configuration
settings, there are also command line options you can use to extend, override
or further specify the report configuration.
2021-04-15 23:18:05 +03:00
.
.SS Common command line options
.
.TP
Definition of the set of fields to use
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.BR -o | --options " " \fIFieldSet
2016-09-12 14:54:37 +03:00
Field set to use. See \fBmain report specifics\fP and
\fBlog report specifics\fP for information about field sets configured with
2020-10-03 14:52:37 +03:00
global configuration settings that this option overrides.
2021-04-15 23:18:05 +03:00
.
.TP
.BR -o | --options " " +\fIFieldSet
2016-09-12 14:54:37 +03:00
Fields to include to current field set. See \fBmain report specifics\fP\ and
\fBlog report specifics\fP for information about field sets configured with
global configuration settings that this option extends.
2021-04-15 23:18:05 +03:00
.
.TP
.BR -o | --options " " -\fIFieldSet
2016-09-12 14:54:37 +03:00
Fields to exclude from current field set. See \fBmain report specifics\fP and
\fBlog report specifics\fP for information about field sets configured with
global configuration settings that this option reduces.
2021-04-15 23:18:05 +03:00
.
.TP
.BR -o | --options " " # \fIFieldSet
2016-09-12 14:54:37 +03:00
Compaction of unused fields. Overrides report/compact_output_cols configuration
setting.
.RE
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Sorting
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.BR -O | --sort " " +\fIFieldSet
2016-09-12 14:54:37 +03:00
Fields to sort by in ascending order. See \fBmain report specifics\fP and
\fBlog report specifics\fP for information about field sets configured with
global configuration settings that this option overrides.
2021-04-15 23:18:05 +03:00
.
.TP
.BR -O | --sort " " -\fIFieldSet
2016-09-12 14:54:37 +03:00
Fields to sort by in descending order. See \fBmain report specifics\fP and
\fBlog report specifics\fP for information about fields sets configured with
global configuration settings that this options overrides.
.RE
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Selection
.RS
2021-04-15 23:18:05 +03:00
.TP
.BR -S | --select " " \fISelection
2016-09-12 14:54:37 +03:00
Define selection criteria for report output. For \fBlog report\fP, this also
overrides log/command_log_selection configuration setting, see also
\fBlog report specifics\fP.
.RE
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Changing output format and composition
.RS
2021-04-15 23:18:05 +03:00
.TP
.B --reportformat
2016-09-12 14:54:37 +03:00
Overrides report/output_format configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --aligned
2016-09-12 14:54:37 +03:00
Overrides report/aligned configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --binary
2016-09-12 14:54:37 +03:00
Overrides report/binary_values_as_numeric configuration setting.
2023-08-22 15:21:58 +03:00
TP
.B --headings
Overrides report/headings congiguration settings.
2021-04-15 23:18:05 +03:00
.TP
.B --nameprefixes
2016-09-12 14:54:37 +03:00
Overrides report/prefixes configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --noheadings
2023-08-22 15:21:58 +03:00
Overrides report/headings configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --nosuffix
2016-09-12 14:54:37 +03:00
Overrides global/suffix configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --rows
2016-09-12 14:54:37 +03:00
Overrides report/columns_as_rows configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --separator
2016-09-12 14:54:37 +03:00
Overrides report/separator configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --units
2016-09-12 14:54:37 +03:00
Overrides global/units configuration setting.
2021-04-15 23:18:05 +03:00
.TP
.B --unquoted
2016-09-12 14:54:37 +03:00
Overrides report/quoted configuration setting.
.RE
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Special options
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.B --configreport \fIReportName
This defines the \fIReportName\fP for which any subsequent
.BR -o | --columns ,
.BR -O | --sort
or
.BR -S | --select
applies to. See also
.B Main report specifics
and
.B Log report specifics
for possible \fIReportName\fP values.
.
.TP
.B --logonly
2016-09-12 14:54:37 +03:00
When an LVM command contains both \fBmain report\fP and \fBlog report\fP,
this option suppresses the \fBmain report\fP output and it causes the
\fBlog report\fP output to be displayed only.
2021-04-15 23:18:05 +03:00
.
.TP
.B --unbuffered
2020-10-03 14:52:37 +03:00
Overrides report/buffered configuration setting.
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.P
The \fIFieldSet\fP mentioned in the lists above is a set of field names where
each field name is delimited by "\fB,\fP" character. Field set definition, sorting
and selection may be repeated on command line (\fB-o\fP\fB+\fP/\fB-o\fP\fB-\fP
includes/excludes fields
2016-09-12 14:54:37 +03:00
to/from current list, for all the other repeatable options, the last value
typed for the option on the command line is used). The \fBSelection\fP
is a string with \fBselection criteria\fP, see also \fBSelection\fP paragraph
below for more information about constructing these criteria.
2021-04-15 23:18:05 +03:00
.
.SS Main report specifics
.
2016-09-12 14:54:37 +03:00
The \fBmain report\fP currently encompasses these distinct subtypes, referenced
2021-04-15 23:18:05 +03:00
by their name - \fIReportName\fP as listed below. The command in parenthesis is
2016-09-12 14:54:37 +03:00
representative command that uses the main report subtype by default.
Each subtype has its own configuration setting for global field set definition
2021-04-15 23:18:05 +03:00
as well as sort field definition (listed below each individual \fIReportName\fP):
.
.ad l
.nh
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
.B pv
representing report about Physical Volumes
(pvs)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/pvs_cols
.br
- report/pvs_sort
.br
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.B pvseg
representing report about Physical Volume Segments
(pvs\ --segments)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/pvseg_cols
.br
- report/pvseg_sort
.br
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.B vg
representing report about Volume Groups (vgs)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/vgs_cols
.br
- report/vgs_sort
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.B lv
representing report about Logical Volumes (lvs)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/lvs_cols
.br
- report/lvs_sort
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.B seg
representing report about Logical Volume Segments
(lvs\ --segments)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/segs_cols
.br
- report/segs_sort
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.B full
representing report combining all of the above as a whole
(lvm\ fullreport)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/pvs_cols_full
.br
- report/pvs_sort_full
.br
- report/pvsegs_cols_full
.br
- report/pvseg_sort_full
.br
- report/vgs_cols_full
.br
- report/vgs_sort_full
.br
- report/lvs_cols_full
.br
- report/lvs_sort_full
.br
- report/segs_cols_full
.br
- report/segs_sort_full
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.B devtype
representing report about device types
(lvm\ devtypes)
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
- report/devtypes_cols
.br
- report/devtypes_sort
2016-09-12 14:54:37 +03:00
.RE
.RE
2021-04-15 23:18:05 +03:00
.ad b
.hy
.P
2016-09-12 14:54:37 +03:00
Use \fBpvs, vgs, lvs -o help\fP or \fBlvm devtypes -o help\fP to get complete
list of fields that you can use for main report. The list of fields in the
help output is separated in groups based on which report type they belong to.
Note that LVM can change final report type used if fields from different
groups are combined together. Some of these combinations are not allowed in
which case LVM will issue an error.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
For all main report subtypes except \fBfull\fP, it's not necessary to use
2021-04-15 23:18:05 +03:00
\fB--configreport\fP \fIReportName\fP to denote which report any subsequent
.BR -o ", " -O
or \fB-S\fP option applies to as they always apply to the single main
2016-09-12 14:54:37 +03:00
report type. Currently, \fBlvm fullreport\fP is the only command that
2021-04-15 23:18:05 +03:00
includes more than one \fBmain report\fP subtype. Therefore, the \fB--configreport\fP
2016-09-12 14:54:37 +03:00
is particularly suitable for the full report if you need to configure each of
its subreports in a different way.
2021-04-15 23:18:05 +03:00
.
.SS Log report specifics
.
2016-09-12 14:54:37 +03:00
You can enable log report with \fBlog/report_command_log\fP configuration
setting - this functionality is disabled by default. The \fBlog report\fP
contains a log collected during LVM command execution and then the log is
displayed just like any other report known from main report. There is only one
log report subtype as shown below together with related configuration settings
for fields, sorting and selection:
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.B log
representing log report
.br
- log/command_log_cols
.br
- log/command_log_sort
.br
- log/command_log_selection
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.P
You always need to use \fB--configreport log\fP together with
.BR -o | --options ", " -O | --sort
or
.BR -S | --selection
to override configuration settings directly on
2016-09-12 14:54:37 +03:00
command line for \fBlog report\fP. When compared to \fBmain report\fP, in
addition to usual configuration settings for report fields and sorting, the
\fBlog report\fP has also configuration option for selection -
\fBreport/command_log_selection\fP. This configuration setting is provided for
2021-04-15 23:18:05 +03:00
convenience so it's not necessary to use
.BR -S | --select
on command line
2016-09-12 14:54:37 +03:00
each time an LVM command is executed and we need the same selection criteria
to be applied for \fBlog report\fP. Default selection criteria used for
\fBlog report\fP are
\fBlog/command_log_selection="!(log_type=status && message=success)"\fP.
This means that, by default, \fBlog report\fP doesn't display status messages
about successful operation and it displays only rows with error, warning,
2017-03-27 17:45:48 +03:00
print-type messages and messages about failure states (for more information,
2016-09-12 14:54:37 +03:00
see \fBlog report content\fP below).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.B Log report coverage
.br
Currently, when running LVM commands directly (not in LVM shell), the log
report covers command's \fBprocessing stage\fP which is the moment when LVM
entities are iterated and processed one by one. It does not cover any command
initialization nor command finalization stage. If there is any message issued
out of log report's coverage range, such message goes directly to output,
bypassing the \fBlog report\fP. By default, that is \fBstandard error output\fP
2017-03-27 17:45:48 +03:00
for error and warning messages and \fBstandard output\fP for common print-like
2016-09-12 14:54:37 +03:00
messages.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
When running LVM commands in \fBLVM shell\fP, the log report covers the whole
LVM command's execution, including command's \fBprocessing\fP as well as
\fBinitialization\fP and \fBfinalization stage\fP. So from this point of view,
the log report coverage is complete for executed LVM commands. Note that there
are still a few moments when LVM shell needs to initialize itself before it
even enters the main loop in which it executes LVM commands. Also, there is a
moment when \fBLVM shell\fP needs to prepare \fBlog report\fP properly for
next command executed in the shell and then, after the command's run, the shell
needs to display the log report for that recently executed command. If there
is a failure or any other message issued during this time, the LVM will bypass
\fBlog report\fP and display messages on output directly.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
For these reasons and for completeness, it's not possible to rely fully on
\fBlog report\fP as the only indicator of LVM command's status and the only
place where all messages issued during LVM command execution are collected.
You always need to check whether the command has not failed out of log
2017-03-27 17:45:48 +03:00
report's range by checking the non-report output too.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
To help with this, LVM can separate output which you can then redirect to
any \fBcustom file descriptor\fP that you prepare before running an LVM
command or LVM shell and then you make LVM to use these file descriptors
for different kinds of output by defining environment variables with file
descriptor numbers. See also \fBLVM_OUT_FD\fP, \fBLVM_ERR_FD\fP and
\fBLVM_REPORT_FD\fP environment variable description in \fBlvm\fP(8)
man page.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Also note that, by default, reports use the same file descriptor as
2017-03-27 17:45:48 +03:00
common print-like messages, which is \fBstandard output\fP. If you plan to
2016-09-12 14:54:37 +03:00
use \fBlog report\fP in your scripts or any external tool, you should use
\fBLVM_OUT_FD\fP, \fBLVM_ERR_FD\fP and \fBLVM_REPORT_FD\fP to separate all
output types to different file descriptors. For example, with bash, that
would be:
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.RS
LVM_OUT_FD=3 LVM_ERR_FD=4 LVM_REPORT_FD=5 <lvm command> 3>out_file 4>err_file 5>report_file
.RE
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Where the <lvm_command> is either direct LVM command or LVM shell.
You can collect all three types of output in particular files then.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.B Log report content
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Each item in the log report consists of these set of fields providing various
information:
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Basic information (mandatory):
.RS
2021-04-15 23:18:05 +03:00
.TP
.I log_seq_num
2016-09-12 14:54:37 +03:00
Item sequence number. The sequence number is unique for each log item and it
increases in the order of the log items as they appeared during LVM command
execution.
2021-04-15 23:18:05 +03:00
.
.TP
.I log_type
2016-09-12 14:54:37 +03:00
Type of log for the item. Currently, these types are used:
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.B status
for any status information that is logged
.
.TP
.B print
for any common message printed while the log is collected
.
.TP
.B error
for any error message printed while the log is collected
.
.TP
.B warn
for any warning message printed while the log is collected
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.I log_context
2016-09-12 14:54:37 +03:00
Context of the log for the item. Currently, two contexts are identified:
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.B shell
for the log collected in the outermost code before and after
2016-09-12 14:54:37 +03:00
executing concrete LVM commands
2021-04-15 23:18:05 +03:00
.
.TP
.B processing
for the log collected while processing LVM entities during
2016-09-12 14:54:37 +03:00
LVM command execution
.RE
.RE
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Message (mandatory):
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.I log_message
2016-09-12 14:54:37 +03:00
Any message associated with current item. For \fBstatus\fP log type,
the message contains either \fBsuccess\fP or \fBfailure\fP denoting
current state. For \fBprint\fP, \fBerror\fP and \fBwarn\fP log types,
the message contains the exact message of that type that got issued.
.RE
2021-04-15 23:18:05 +03:00
.
.TP
2016-09-12 14:54:37 +03:00
Object information (used only if applicable):
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.I log_object_type field
2016-09-12 14:54:37 +03:00
Type of the object processed. Currently, these object types are recognized:
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.B cmd
for command as a whole
.
.TP
.B orphan
for processing group of PVs not in any VG yet
.
.TP
.B pv
for PV processing
.
.TP
.B label
for direct PV label processing (without VG metadata)
.
.TP
.B vg
for VG processing
.
.TP
.B lv
for LV processing
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.
.TP
.I log_object_name
2016-09-12 14:54:37 +03:00
Name of the object processed.
2021-04-15 23:18:05 +03:00
.
.TP
.I log_object_id
2016-09-12 14:54:37 +03:00
ID of the object processed.
2021-04-15 23:18:05 +03:00
.
.TP
.I log_object_group
2016-09-12 14:54:37 +03:00
A group where the processed object belongs to.
2021-04-15 23:18:05 +03:00
.
.TP
.I log_object_group_id
2016-09-12 14:54:37 +03:00
An ID of a group where the processed object belongs to.
.RE
2021-04-15 23:18:05 +03:00
.
.TP
Numeric status (used only if applicable):
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.
.TP
.I log_errno
2016-09-12 14:54:37 +03:00
Error number associated with current item.
2021-04-15 23:18:05 +03:00
.
.TP
.I log_ret_code
Return code associated with current item.
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.P
You can also run \fBlvm --configreport log -o help\fP to
2016-09-12 14:54:37 +03:00
to display complete list of fields that you may use for the \fBlog report\fP.
2021-04-15 23:18:05 +03:00
.
.SS Selection
.
2016-09-12 14:54:37 +03:00
Selection is used for a report to display only rows that match
\fBselection criteria\fP. All rows are displayed with the additional
2017-03-27 17:45:48 +03:00
\fBselected\fP field (\fB-o selected\fP) displaying 1 if the row matches the
2016-09-12 14:54:37 +03:00
\fISelection\fP and 0 otherwise. The \fBselection criteria\fP are a set of
\fBstatements\fP combined by \fBlogical and grouping operators\fP.
The \fBstatement\fP consists of a \fBfield\fP name for which a set of valid
\fBvalues\fP is defined using \fBcomparison operators\fP. For complete list
of fields names that you can use in selection, see the output of
2021-04-15 23:18:05 +03:00
\fBlvm -S help\fP. The help output also contains type of values
2016-09-12 14:54:37 +03:00
that each field displays enclosed in brackets.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.B List of operators recognized in selection criteria
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
Comparison operators (\fIcmp_op\fP)
.PD 0
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
.B =~
matching regular expression.
.TP
.B !~
not matching regular expression.
.TP
.B =
equal to.
.TP
.B !=
not equal to.
.TP
.B >=
greater than or equal to.
.TP
.B >
greater than
.TP
.B <=
less than or equal to.
.TP
.B <
less than.
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.PD
.
.TP
Binary logical operators (\fIcmp_log\fP)
.PD 0
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
.B &&
all fields must match
.TP
.B ,
all fields must match
.TP
.B ||
at least one field must match
.TP
.B #
at least one field must match
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.PD
.
.TP
2016-09-12 14:54:37 +03:00
Unary logical operators
2021-04-15 23:18:05 +03:00
.PD 0
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
.B !
logical negation
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.PD
.
.TP
2016-09-12 14:54:37 +03:00
Grouping operators
2021-04-15 23:18:05 +03:00
.PD 0
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
.B (
left parenthesis
.TP
.B )
right parenthesis
.TP
.B [
list start
.TP
.B ]
list end
.TP
.B {
list subset start
.TP
.B }
list subset end
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.PD
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.B Field types and selection operands
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Field type restricts the set of operators and values that you may use with
the field when defining selection criteria. You can see field type for each
2021-04-15 23:18:05 +03:00
field if you run \fBlvm -S help\fP where you can find the type name
2016-09-12 14:54:37 +03:00
enclosed in square brackets. Currently, LVM recognizes these field types in
reports:
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.TP
.B string
for set of characters (for each string field type, you can use
2016-09-12 14:54:37 +03:00
either string or regular expression - regex for the value used in selection
criteria)
2021-04-15 23:18:05 +03:00
.TP
.B string list
for set of strings
.TP
.B number
for integer value
.TP
.B size
for integer or floating point number with size unit suffix
2017-03-27 17:45:48 +03:00
(see also \fBlvcreate\fP(8) man page and description for "-L|--size"
2016-09-12 14:54:37 +03:00
option for the list of recognized suffixes)
2021-04-15 23:18:05 +03:00
.TP
.B percent\fP for floating point number with or without "%" suffix
2016-09-12 14:54:37 +03:00
(e.g. 50 or 50%)
2021-04-15 23:18:05 +03:00
.TP
.B time
for time values
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
When using \fBstring list\fP in selection criteria, there are several ways
how LVM can match string list fields from report, depending on what list
grouping operator is used and what item separator is used within that set
of items. Also, note that order of items does not matter here.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.IP \[bu] 3
\fBmatching the set strictly\fP where all items must match - use [ ], e.g.
["a","b","c"]
2021-04-15 23:18:05 +03:00
.IP \[bu]
2016-09-12 14:54:37 +03:00
\fBmatching a subset of the set\fP - use { } with "," or "&&" as item
delimiter, e.g. {"a","b","c"}
2021-04-15 23:18:05 +03:00
.IP \[bu]
2016-09-12 14:54:37 +03:00
\fBmatching an intersection with the set\fP - use { } with "#" or
"||" as item delimiter, e.g. {"a" || "b" || "c"}
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
When using \fBtime\fP in your selection criteria, LVM can recognize various
time formats using standard, absolute or freeform expressions. For examples
demonstrating time expressions in selection criteria, see \fBEXAMPLES\fP section.
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.IP \[bu] 3
2021-04-15 23:18:05 +03:00
.B Standard time format
2016-09-12 14:54:37 +03:00
.RS
.IP - 3
date
.RS
2021-04-15 23:18:05 +03:00
.RS
2017-03-27 17:45:48 +03:00
YYYY-MM-DD
2021-04-15 23:18:05 +03:00
.br
2017-03-27 17:45:48 +03:00
YYYY-MM, auto DD=1
2021-04-15 23:18:05 +03:00
.br
2016-09-12 14:54:37 +03:00
YYYY, auto MM=01 and DD=01
.RE
2021-04-15 23:18:05 +03:00
.RE
.
.IP -
2016-09-12 14:54:37 +03:00
time
.RS
2021-04-15 23:18:05 +03:00
.RS
2016-09-12 14:54:37 +03:00
hh:mm:ss
2021-04-15 23:18:05 +03:00
.br
2016-09-12 14:54:37 +03:00
hh:mm, auto ss=0
2021-04-15 23:18:05 +03:00
.br
2016-09-12 14:54:37 +03:00
hh, auto mm=0, auto ss=0
.RE
2021-04-15 23:18:05 +03:00
.RE
.
.IP -
2016-09-12 14:54:37 +03:00
timezone
.RS
2021-04-15 23:18:05 +03:00
.RS
2016-09-12 14:54:37 +03:00
+hh:mm or -hh:mm
2021-04-15 23:18:05 +03:00
.br
2016-09-12 14:54:37 +03:00
+hh or -hh
.RE
2021-04-15 23:18:05 +03:00
.RE
.P
2017-03-27 17:45:48 +03:00
The full date/time specification is YYYY-MM-DD hh:mm:ss. Users are able
2016-09-12 14:54:37 +03:00
to leave date/time parts from right to left. Whenever these parts are left out,
a range is assumed automatically with second granularity. For example:
2021-04-15 23:18:05 +03:00
.P
.nf
"2015-07-07 9:51" means range of "2015-07-07 9:51:00" - "2015-07-07 9:51:59"
2016-09-12 14:54:37 +03:00
"2015-07" means range of "2015-07-01 0:00:00" - "2015-07-31 23:59:59"
"2015" means range of "2015-01-01 0:00:00" - "2015-12-31 23:59:59"
2021-04-15 23:18:05 +03:00
.fi
2016-09-12 14:54:37 +03:00
.RE
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.IP \[bu] 3
2021-04-15 23:18:05 +03:00
.B Absolute time format
.br
2016-09-12 14:54:37 +03:00
Absolute time is defined as number of seconds since the Epoch
(1970:01:01 00:00 +00:00).
.RS
.IP - 3
@seconds
.RE
.IP \[bu] 3
2021-04-15 23:18:05 +03:00
.B Freeform time format
2016-09-12 14:54:37 +03:00
.RS
2021-04-15 23:18:05 +03:00
.PD 0
2016-09-12 14:54:37 +03:00
.IP - 3
weekday names ("Sunday" - "Saturday" or abbreviated as "Sun" - "Sat")
2021-04-15 23:18:05 +03:00
.IP -
2016-09-12 14:54:37 +03:00
labels for points in time ("noon", "midnight")
2021-04-15 23:18:05 +03:00
.IP -
2016-09-12 14:54:37 +03:00
labels for a day relative to current day ("today", "yesterday")
2021-04-15 23:18:05 +03:00
.IP -
2016-09-12 14:54:37 +03:00
points back in time with relative offset from today (N is a number)
.RS
.IP
"N" "seconds" / "minutes" / "hours" / "days" / "weeks" / "years" "ago"
.IP
"N" "secs" / "mins" / "hrs" ... "ago"
.IP
"N" "s" / "m" / "h" ... "ago"
.RE
.IP - 3
time specification either in hh:mm:ss format or with AM/PM suffixes
2021-04-15 23:18:05 +03:00
.IP -
2016-09-12 14:54:37 +03:00
month names ("January" - "December" or abbreviated as "Jan" - "Dec")
.RE
2021-04-15 23:18:05 +03:00
.PD
.P
2016-09-12 14:54:37 +03:00
.B Informal grammar specification
2021-04-15 23:18:05 +03:00
.IP - 2
.B STATEMENT = column \fIcmp_op\fP VALUE \fR|
.B STATEMENT \fIlog_op\fP STATEMENT \fR|
.B (STATEMENT) \fR|\fP !(STATEMENT)
.IP -
.B VALUE = [VALUE \fIlog_op\fP VALUE]
2016-09-12 14:54:37 +03:00
.br
2017-03-27 17:45:48 +03:00
For list-based types: string list. Matches strictly.
2016-09-12 14:54:37 +03:00
The log_op must always be of one type within the whole list value.
2021-04-15 23:18:05 +03:00
.IP -
.B VALUE = {VALUE \fIlog_op\fP VALUE}
2016-09-12 14:54:37 +03:00
.br
2017-03-27 17:45:48 +03:00
For list-based types: string list. Matches a subset.
2016-09-12 14:54:37 +03:00
The log_op must always be of one type within the whole list value.
2021-04-15 23:18:05 +03:00
.IP -
2016-09-12 14:54:37 +03:00
.BR VALUE " = " value
.br
For scalar types: number, size, percent, string (or string regex).
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SH EXAMPLES
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Basic usage
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
We start our examples with default configuration - \fBlvmconfig\fP(8) is
helpful command to display configuration settings which are currently used,
including all configuration related to reporting. We will use it throughout
examples below to display current configuration.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full global/units global/suffix \\
2016-09-12 14:54:37 +03:00
report/output_format report/compact_output \\
report/compact_output_cols report/aligned \\
report/headings report/separator \\
report/list_item_separator report/prefixes \\
report/quoted report/columns_as_rows \\
report/binary_values_as_numeric report/time_format \\
report/mark_hidden_devices report/two_word_unknown_device \\
report/buffered
units="h"
suffix=1
output_format="basic"
compact_output=0
compact_output_cols=""
aligned=1
headings=1
separator=" "
list_item_separator=","
prefixes=0
quoted=1
columns_as_rows=0
binary_values_as_numeric=0
2017-03-27 17:45:48 +03:00
time_format="%Y-%m-%d %T %z"
2016-09-12 14:54:37 +03:00
mark_hidden_devices=1
two_word_unknown_device=0
buffered=1
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Also, we start with simple LVM layout with two PVs (/dev/sda, /dev/sdb),
VG (vg) and two LVs (lvol0 and lvol1) in the VG. We display all possible
reports as single commands here, see also \fBpvs\fP(8), \fBvgs\fP(8),
\fBlvs\fP(8) man pages for more information. The field set for each report
type is configured with configuration settings as we already mentioned in
\fBmain report specifics\fP section in this man page.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/pvs_cols report/pvs_sort \\
2016-09-12 14:54:37 +03:00
report/pvsegs_cols report/pvsegs_sort report/vgs_cols \\
report/vgs_sort report/lvs_cols report/lvs_sort \\
report/segs_cols report/segs_sort
pvs_cols="pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
pvs_sort="pv_name"
pvsegs_cols="pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,
pvseg_start,pvseg_size"
pvsegs_sort="pv_name,pvseg_start"
vgs_cols="vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
vgs_sort="vg_name"
lvs_cols="lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,move_pv,
mirror_log,copy_percent,convert_lv"
lvs_sort="vg_name,lv_name"
segs_cols="lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
segs_sort="vg_name,lv_name,seg_start"
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# pvs
2021-04-13 16:26:54 +03:00
PV VG Fmt Attr PSize PFree
2017-03-27 17:45:48 +03:00
/dev/sda vg lvm2 a-- 100.00m 88.00m
/dev/sdb vg lvm2 a-- 100.00m 92.00m
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
# pvs --segments
2016-09-12 14:54:37 +03:00
PV VG Fmt Attr PSize PFree Start SSize
2017-03-27 17:45:48 +03:00
/dev/sda vg lvm2 a-- 100.00m 88.00m 0 1
/dev/sda vg lvm2 a-- 100.00m 88.00m 1 1
/dev/sda vg lvm2 a-- 100.00m 88.00m 2 1
/dev/sda vg lvm2 a-- 100.00m 88.00m 3 22
/dev/sdb vg lvm2 a-- 100.00m 92.00m 0 1
/dev/sdb vg lvm2 a-- 100.00m 92.00m 1 1
/dev/sdb vg lvm2 a-- 100.00m 92.00m 2 23
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# vgs
2021-04-13 16:26:54 +03:00
VG #PV #LV #SN Attr VSize VFree
2017-03-27 17:45:48 +03:00
vg 2 2 0 wz--n- 200.00m 180.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
LV VG Attr LSize Pool Origin Move Log Cpy%Sync Convert
2021-04-13 16:26:54 +03:00
lvol0 vg -wi-a----- 4.00m
lvol1 vg rwi-a-r--- 4.00m 100.00
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs --segments
2016-09-12 14:54:37 +03:00
LV VG Attr #Str Type SSize
2017-03-27 17:45:48 +03:00
lvol0 vg -wi-a----- 1 linear 4.00m
lvol1 vg rwi-a-r--- 2 raid1 4.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
We will use \fBreport/lvs_cols\fP and \fBreport/lvs_sort\fP configuration
settings to define our own list of fields to use and to sort by that is
different from defaults. You can do this for other reports in same manner
with \fBreport/{pvs,pvseg,vgs,seg}_{cols,sort}\fP configuration settings.
Also note that in the example below, we don't display the "lv_time" field
even though we're using it for sorting - this is allowed.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/lvs_cols report/lvs_sort
2016-09-12 14:54:37 +03:00
lvs_cols="lv_name,lv_size,origin,pool_lv,copy_percent"
lvs_sort="-lv_time"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
LV LSize Origin Pool Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
You can use
.BR -o | --options
command line option to override current
2016-09-12 14:54:37 +03:00
configuration directly on command line.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o lv_name,lv_size
LV LSize
lvol1 4.00m
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o+lv_layout
2021-04-13 16:26:54 +03:00
LV LSize Origin Pool Cpy%Sync Layout
2016-09-12 14:54:37 +03:00
lvol1 4.00m 100.00 raid,raid1
2021-04-13 16:26:54 +03:00
lvol0 4.00m linear
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -o-origin
2016-09-12 14:54:37 +03:00
LV LSize Pool Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -o lv_name,lv_size,origin -o+lv_layout -o-origin -O lv_name
2021-04-13 16:26:54 +03:00
LV LSize Layout
lvol0 4.00m linear
2016-09-12 14:54:37 +03:00
lvol1 4.00m raid,raid1
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
You can obtain the same information with single command where all the
information about PVs, PV segments, LVs and LV segments are obtained
2021-04-15 23:18:05 +03:00
per VG under a single VG lock for consistency, see also \fBlvm fullreport\fP(8)
2016-09-12 14:54:37 +03:00
man page for more information. The fullreport has its own configuration
settings to define field sets to use, similar to individual reports as
displayed above, but configuration settings have "_full" suffix now.
This way, it's possible to configure different sets of fields to display
and to sort by for individual reports as well as the full report.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/pvs_cols_full \\
2016-09-12 14:54:37 +03:00
report/pvs_sort_full report/pvsegs_cols_full \\
report/pvsegs_sort_full report/vgs_cols_full \\
report/vgs_sort_full report/lvs_cols_full \\
report/lvs_sort_full report/segs_cols_full \\
report/segs_sort_full
pvs_cols_full="pv_name,vg_name"
pvs_sort_full="pv_name"
pvsegs_cols_full="pv_name,pvseg_start,pvseg_size"
pvsegs_sort_full="pv_uuid,pvseg_start"
vgs_cols_full="vg_name"
vgs_sort_full="vg_name"
lvs_cols_full="lv_name,vg_name"
lvs_sort_full="vg_name,lv_name"
segs_cols_full="lv_name,seg_start,seg_size"
segs_sort_full="lv_uuid,seg_start"
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvm fullreport
VG
vg
PV VG
/dev/sda vg
/dev/sdb vg
LV VG
lvol0 vg
lvol1 vg
PV Start SSize
/dev/sda 0 1
/dev/sda 1 1
/dev/sda 2 1
/dev/sda 3 22
/dev/sdb 0 1
/dev/sdb 1 1
/dev/sdb 2 23
LV Start SSize
lvol0 0 4.00m
lvol1 0 4.00m
.fi
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Automatic output compaction
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
If you look at the lvs output above, you can see that the report also contains
fields for which there is no information to display (e.g. the columns under
"Origin" and "Pool" heading - the "origin" and "pool_lv" fields). LVM can
automatically compact report output so such fields are not included in final
output. To enable this feature and to compact all fields, use
\fBreport/compact_output=1\fP in your configuration.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/compact_output
2016-09-12 14:54:37 +03:00
compact_output=1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs vg/lvol0
2021-04-13 16:26:54 +03:00
LV LSize
2016-09-12 14:54:37 +03:00
lvol0 4.00m
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Alternatively, you can define which fields should be compacted by configuring
2021-04-15 23:18:05 +03:00
\fBreport/compact_output_cols\fP configuration setting (or
.BR -o | --options " " #
2016-09-12 14:54:37 +03:00
command line option).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/compact_output report/compact_output_cols
2016-09-12 14:54:37 +03:00
compact_output=0
compact_output_cols="origin"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
LV LSize Pool Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs vg/lvol0
2021-04-13 16:26:54 +03:00
LV LSize Pool
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2021-04-13 16:26:54 +03:00
# lvs -o#pool_lv
2016-09-12 14:54:37 +03:00
LV LSize Origin Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
We will use \fBreport/compact_output=1\fP for subsequent examples.
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Further formatting options
2021-04-15 23:18:05 +03:00
.
2017-03-27 17:45:48 +03:00
By default, LVM displays sizes in reports in human-readable form which means
2016-09-12 14:54:37 +03:00
that the most suitable unit is used so it's easy to read. You can use
2017-03-27 17:45:48 +03:00
\fBreport/units\fP configuration setting (or \fB--units\fP option directly
2016-09-12 14:54:37 +03:00
on command line) and \fBreport/suffix\fP
2017-03-27 17:45:48 +03:00
configuration setting (or \fB--nosuffix\fP command line option) to change this.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --units b --nosuffix
2016-09-12 14:54:37 +03:00
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4194304 100.00
lvol0 4194304
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
If you want to configure whether report headings are displayed or not, use
2017-03-27 17:45:48 +03:00
\fBreport/headings\fP configuration settings (or \fB--noheadings\fP command
2016-09-12 14:54:37 +03:00
line option).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --noheadings
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
In some cases, it may be useful to display report content as key=value pairs
where key here is actually the field name. Use \fBreport/prefixes\fP
2017-03-27 17:45:48 +03:00
configuration setting (or \fB--nameprefixes\fP command line option) to switch
2016-09-12 14:54:37 +03:00
between standard output and the key=value output. The key=value pair is the
output that is suitable for use in scripts and for other tools to parse easily.
Usually, you also don't want to display headings with the output that has these
key=value pairs.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --noheadings --nameprefixes
2016-09-12 14:54:37 +03:00
LVM2_LV_NAME='lvol1' LVM2_LV_SIZE='4.00m' LVM2_COPY_PERCENT='100.00'
LVM2_LV_NAME='lvol0' LVM2_LV_SIZE='4.00m' LVM2_COPY_PERCENT=''
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
To define whether quotation marks in key=value pairs should be used or not,
2017-03-27 17:45:48 +03:00
use \fBreport/quoted\fP configuration setting (or \fB--unquoted\fP command
2016-09-12 14:54:37 +03:00
line option).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --noheadings --nameprefixes --unquoted
2016-09-12 14:54:37 +03:00
LVM2_LV_NAME=lvol1 LVM2_LV_SIZE=4.00m LVM2_COPY_PERCENT=100.00
LVM2_LV_NAME=lvol0 LVM2_LV_SIZE=4.00m LVM2_COPY_PERCENT=
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
For easier parsing, you can even transpose the report so each column now
becomes a row in the output. This is done with \fBreport/output_as_rows\fP
2017-03-27 17:45:48 +03:00
configuration setting (or \fB--rows\fP command line option).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --noheadings --nameprefixes --unquoted --rows
2016-09-12 14:54:37 +03:00
LVM2_LV_NAME=lvol1 LVM2_LV_NAME=lvol0
LVM2_LV_SIZE=4.00m LVM2_LV_SIZE=4.00m
LVM2_COPY_PERCENT=100.00 LVM2_COPY_PERCENT=
.fi
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
Use \fBreport/separator\fP configuration setting (or \fB--separator\fP command
2016-09-12 14:54:37 +03:00
line option) to define your own field separator to use.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --noheadings --nameprefixes --unquoted --separator " | "
2016-09-12 14:54:37 +03:00
LVM2_LV_NAME=lvol1 | LVM2_LV_SIZE=4.00m | LVM2_COPY_PERCENT=100.00
LVM2_LV_NAME=lvol0 | LVM2_LV_SIZE=4.00m | LVM2_COPY_PERCENT=
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
If you are using your own separator, the columns in the output are not aligned
2017-03-27 17:45:48 +03:00
by default. Use \fBreport/aligned\fP configuration setting (or \fB--aligned\fP
2016-09-12 14:54:37 +03:00
command line option) for LVM to add extra spaces in report to align the output
properly.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs --separator " | "
2016-09-12 14:54:37 +03:00
LV | LSize | Cpy%Sync
lvol1 | 4.00m | 100.00
2021-04-13 16:26:54 +03:00
lvol0 | 4.00m |
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs --separator " | " --aligned
2016-09-12 14:54:37 +03:00
LV | LSize | Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 | 4.00m | 100.00
lvol0 | 4.00m |
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Let's display one one more field in addition ("lv_tags" in this example)
for the lvs report output.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o+lv_tags
2021-04-13 16:26:54 +03:00
LV LSize Cpy%Sync LV Tags
lvol1 4.00m 100.00
2016-09-12 14:54:37 +03:00
lvol0 4.00m tagA,tagB
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
The "LV Tags" column in the example above displays two list values,
separated by "," character for LV lvol0. If you need different list item
separator, use \fBreport/list_item_separator\fP configuration setting its
definition.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/list_item_separator
2016-09-12 14:54:37 +03:00
list_item_separator=";"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o+tags
2021-04-13 16:26:54 +03:00
LV LSize Cpy%Sync LV Tags
lvol1 4.00m 100.00
2016-09-12 14:54:37 +03:00
lvol0 4.00m tagA;tagB
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
But let's still use the original "," character for list_item_separator
for subsequent examples.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Format for any of time values displayed in reports can be configured with
2022-12-30 14:52:49 +03:00
\fBreport/time_format\fP configuration setting. By default complete date
2016-09-12 14:54:37 +03:00
and time is displayed, including timezone.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/time_format
time_format="%Y-%m-%d %T %z"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o+time
2021-04-13 16:26:54 +03:00
LV LSize Cpy%Sync CTime
lvol1 4.00m 100.00 2016-08-29 12:53:36 +0200
lvol0 4.00m 2016-08-29 10:15:17 +0200
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
We can change time format in similar way as we do when using \fBdate\fP(1)
command or \fBstrftime\fP(3) function
2017-03-27 17:45:48 +03:00
(\fBlvmconfig --type default --withcomments report/time_format\fP will
2016-09-12 14:54:37 +03:00
give you complete list of available formatting options). In the example
below, we decided to use %s for number of seconds since Epoch (1970-01-01 UTC).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/time_format
2016-09-12 14:54:37 +03:00
time_format="%s"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
2021-04-13 16:26:54 +03:00
LV Attr LSize Cpy%Sync LV Tags CTime
lvol1 rwi-a-r--- 4.00m 100.00 1472468016
lvol0 -wi-a----- 4.00m tagA,tagB 1472458517
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
The \fBlvs\fP does not display hidden LVs by default - to include these LVs
2017-03-27 17:45:48 +03:00
in the output, you need to use \fB-a|--all\fP command line option. Names for
2016-09-12 14:54:37 +03:00
these hidden LVs are displayed within square brackets.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -a
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
[lvol1_rimage_0] 4.00m
[lvol1_rmeta_0] 4.00m
[lvol1_rimage_1] 4.00m
[lvol1_rmeta_1] 4.00m
lvol0 4.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
You can configure LVM to display the square brackets for hidden LVs or not with
\fBreport/mark_hidden_devices\fP configuration setting.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/mark_hidden_devices
2016-09-12 14:54:37 +03:00
mark_hidden_devices=0
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -a
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol1_rimage_0 4.00m
lvol1_rmeta_0 4.00m
lvol1_rimage_1 4.00m
lvol1_rmeta_1 4.00m
lvol0 4.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
It's not recommended to use LV marks for hidden devices to decide whether the
LV is the one to use by end users or not. Please, use "lv_role" field instead
which can report whether the LV is "public" or "private". The private LVs are
used by LVM only and they should not be accessed directly by end users.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -a -o+lv_role
2021-04-13 16:26:54 +03:00
LV LSize Cpy%Sync Role
lvol1 4.00m 100.00 public
lvol1_rimage_0 4.00m private,raid,image
2016-09-12 14:54:37 +03:00
lvol1_rmeta_0 4.00m private,raid,metadata
2021-04-13 16:26:54 +03:00
lvol1_rimage_1 4.00m private,raid,image
2016-09-12 14:54:37 +03:00
lvol1_rmeta_1 4.00m private,raid,metadata
2021-04-13 16:26:54 +03:00
lvol0 4.00m public
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Some of the reporting fields that LVM reports are of binary nature. For such
fields, it's either possible to display word representation of the value
(this is used by default) or numeric value (0/1 or -1 in case the value is
undefined).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o+lv_active_locally
2021-04-13 16:26:54 +03:00
LV LSize Cpy%Sync ActLocal
2016-09-12 14:54:37 +03:00
lvol1 4.00m 100.00 active locally
lvol0 4.00m active locally
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
We can change the way how these binary values are displayed with
\fBreport/binary_values_as_numeric\fP configuration setting.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full report/binary_values_as_numeric
2016-09-12 14:54:37 +03:00
binary_values_as_numeric=1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o+lv_active_locally
2021-04-13 16:26:54 +03:00
LV LSize Cpy%Sync ActLocal
2016-09-12 14:54:37 +03:00
lvol1 4.00m 100.00 1
lvol0 4.00m 1
.fi
2023-08-22 15:21:58 +03:00
.P
In certain cases, you may find it more useful to report full column names
instead of abbreviated column names in report headings. To do this, use
\fBreport/headings=2\fP configuration setting (or \fB--headings full\fP
or \fB--headings 2\fP command line option). The full column names are
the exact names that you also use in \fIFieldSet\fP for \fB-o|--options\fP.
These names are unambiguous, without spaces (one word only) and they also
make it easier to match the output with requested \fIFieldSet\fP:
.P
.nf
# lvs -o+seg_start,seg_start_pe
LV VG LSize Cpy%Sync Start Start
lvol0 vg 4.00m 0 0
lvol1 vg 4.00m 100.00 0 0
# lvs --headings full -o+seg_start,seg_start_pe
lv_name vg_name lv_size copy_percent seg_start seg_start_pe
lvol0 vg 4.00m 0 0
lvol1 vg 4.00m 100.00 0 0
.fi
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Changing output format
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
LVM can output reports in different formats - use \fBreport/output_format\fP
2022-12-30 14:52:49 +03:00
configuration setting (or \fB--reportformat\fP command line option) to switch
2022-08-04 17:52:22 +03:00
the report output format.
2021-04-15 23:18:05 +03:00
.P
2022-12-30 14:52:49 +03:00
Currently, LVM supports these output formats:
2022-08-04 17:52:22 +03:00
.RS
- \fB"basic"\fP (all the examples we used above used this format),
.br
- \fB"json"\fP,
.br
- \fB"json_std"\fP.
.RE
.P
For example:
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -o lv_name,lv_size --reportformat json
2016-09-12 14:54:37 +03:00
{
"report": [
{
"lv": [
{"lv_name":"lvol1", "lv_size":"4.00m"},
{"lv_name":"lvol0", "lv_size":"4.00m"}
]
}
]
}
.fi
2021-04-15 23:18:05 +03:00
.P
2022-08-04 17:52:22 +03:00
The \fBjson_std\fP output format is more compliant with JSON standard and
compared to the original \fBjson\fP format:
.RS
- it does not use double quotes around numeric values,
.br
2022-08-15 12:40:52 +03:00
- numeric values are always expressed as numbers, not reserved strings
representing them (this also means that report/binary_values_as_numeric=1
setting is forced)
.br
2022-08-04 17:52:22 +03:00
- it uses 'null' for undefined numeric values,
.br
- it prints string list as proper JSON array of strings instead of a single string.
.RE
.P
2016-09-12 14:54:37 +03:00
Note that some configuration settings and command line options have no
2022-08-04 17:52:22 +03:00
effect with certain report formats. For example, with \fBjson\fP or
\fBjson_std\fP output, it doesn't have any meaning to use \fBreport/aligned\fP
(\fB--aligned\fP), \fBreport/noheadings\fP (\fB--noheadings\fP),
\fBreport/columns_as_rows\fP (\fB--rows\fP) or \fBreport/buffered\fP
(\fB--unbuffered\fP). All these configuration settings and command line options
are ignored if using the \fBjson\fP or \fBjson_std\fP report output format.
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Selection
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
If you need to select only specific rows from report, you can use LVM's
2021-04-15 23:18:05 +03:00
report selection feature. If you call \fBlvm -S help\fP, you'll get
2016-09-12 14:54:37 +03:00
quick help on selection. The help contains list of all fields that LVM
can use in reports together with its type enclosed in square brackets.
The example below contains a line from lvs -S help.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -S help
...
lv_size - Size of LV in current units. [size]
...
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
This line tells you you that the "lv_size" field is of "size" type. If you
look at the bottom of the help output, you can see section about
"Selection operators" and its "Comparison operators".
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -S help
...
Selection operators
2017-03-27 17:45:48 +03:00
-------------------
2016-09-12 14:54:37 +03:00
Comparison operators:
=~ - Matching regular expression. [regex]
!~ - Not matching regular expression. [regex]
= - Equal to. [number, size, percent, string, string list, time]
!= - Not equal to. [number, size, percent, string, string_list, time]
>= - Greater than or equal to. [number, size, percent, time]
> - Greater than. [number, size, percent, time]
<= - Less than or equal to. [number, size, percent, time]
< - Less than. [number, size, percent, time]
since - Since specified time (same as '>='). [time]
after - After specified time (same as '>'). [time]
until - Until specified time (same as '<='). [time]
2021-04-15 23:18:05 +03:00
before - Before specified time (same as '<'). [time]
2016-09-12 14:54:37 +03:00
...
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Here you can match comparison operators that you may use with the "lv_size"
field which is of type "size" - it's =, !=, >=, >, <= and <. You can find
applicable comparison operators for other fields and other field types the
same way.
2021-04-15 23:18:05 +03:00
.P
2020-10-03 14:52:37 +03:00
To demonstrate selection functionality in LVM, we will create more LVs in
2016-09-12 14:54:37 +03:00
addition to lvol0 and lvol1 we used in our previous examples.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,size,origin,snap_percent,tags,time
2021-04-13 16:26:54 +03:00
LV LSize Origin Snap% LV Tags CTime
lvol4 4.00m lvol2 24.61 2016-09-09 16:57:44 +0200
lvol3 4.00m lvol2 5.08 2016-09-09 16:56:48 +0200
lvol2 8.00m tagA,tagC,tagD 2016-09-09 16:55:12 +0200
lvol1 4.00m 2016-08-29 12:53:36 +0200
2016-09-12 14:54:37 +03:00
lvol0 4.00m tagA,tagB 2016-08-29 10:15:17 +0200
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
When selecting size and percent fields, we don't need to use units.
For sizes, default "m" (for MiB) is used - this is the same behaviour
as already used for LVM commands when specifying sizes (e.g. lvcreate -L).
For percent fields, "%" is assumed automatically if it's not specified.
The example below also demonstrates how several criteria can be combined
together.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,size,snap_percent -S 'size=8m'
2021-04-13 16:26:54 +03:00
LV LSize
2016-09-12 14:54:37 +03:00
lvol2 8.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,size,snap_percent -S 'size=8'
2021-04-13 16:26:54 +03:00
LV LSize
2016-09-12 14:54:37 +03:00
lvol2 8.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,size,snap_percent -S 'size < 5000k'
2021-04-13 16:26:54 +03:00
LV LSize Snap%
lvol4 4.00m 24.61
lvol3 4.00m 5.08
lvol1 4.00m
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,size,snap_percent -S 'size < 5000k && snap_percent > 20'
2021-04-13 16:26:54 +03:00
LV LSize Snap%
lvol4 4.00m 24.61
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,size,snap_percent \\
-S '(size < 5000k && snap_percent > 20%) || name=lvol2'
2021-04-13 16:26:54 +03:00
LV LSize Snap%
lvol4 4.00m 24.61
lvol2 8.00m
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
You can also use selection together with processing-oriented commands.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvchange --addtag test -S 'size < 5000k'
2016-09-12 14:54:37 +03:00
Logical volume vg/lvol1 changed.
Logical volume vg/lvol0 changed.
Logical volume vg/lvol3 changed.
Logical volume vg/lvol4 changed.
2021-04-15 23:18:05 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvchange --deltag test -S 'tags = test'
2016-09-12 14:54:37 +03:00
Logical volume vg/lvol1 changed.
Logical volume vg/lvol0 changed.
Logical volume vg/lvol3 changed.
Logical volume vg/lvol4 changed.
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
LVM can recognize more complex values used in selection criteria for
string list and time field types. For string lists, you can match
whole list strictly, its subset or intersection. Let's take "lv_tags"
field as an example - we select only rows which contain "tagA" within
tags field. We're using { } to denote that we're interested in subset
that matches. If the subset has only one item, we can leave out { }.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,tags -S 'tags={tagA}'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol2 tagA,tagC,tagD
2021-04-13 16:26:54 +03:00
lvol0 tagA,tagB
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,tags -S 'tags=tagA'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol2 tagA,tagC,tagD
2021-04-13 16:26:54 +03:00
lvol0 tagA,tagB
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Depending on whether we use "&&" (or ",") or "||" ( or "#") as delimiter
for items in the set we define in selection criterion for string list,
we either match subset ("&&" or ",") or even intersection ("||" or "#").
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,tags -S 'tags={tagA,tagC,tagD}'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol2 tagA,tagC,tagD
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,tags -S 'tags={tagA || tagC || tagD}'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol2 tagA,tagC,tagD
2021-04-13 16:26:54 +03:00
lvol0 tagA,tagB
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
To match the complete set, use [ ] with "&&" (or ",") as delimiter for items.
Also note that the order in which we define items in the set is not relevant.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2021-04-13 16:26:54 +03:00
# lvs -o name,tags -S 'tags=[tagA]'
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,tags -S 'tags=[tagB,tagA]'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol0 tagA,tagB
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
If you use [ ] with "||" (or "#"), this is exactly the same as using { }.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,tags -S 'tags=[tagA || tagC || tagD]'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol2 tagA,tagC,tagD
2021-04-13 16:26:54 +03:00
lvol0 tagA,tagB
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
To match a set with no items, use "" to denote this (note that we have
output compaction enabled so the "LV Tags" column is not displayed in
the example below because it's blank and so it gets compacted).
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,tags -S 'tags=""'
2021-04-13 16:26:54 +03:00
LV
2016-09-12 14:54:37 +03:00
lvol4
lvol3
lvol1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,tags -S 'tags!=""'
2021-04-13 16:26:54 +03:00
LV LV Tags
2016-09-12 14:54:37 +03:00
lvol2 tagA,tagC,tagD
2021-04-13 16:26:54 +03:00
lvol0 tagA,tagB
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
When doing selection based on time fields, we can use either standard,
absolute or freeform time expressions in selection criteria. Examples below
are using standard forms.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,time
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "2016-09-01"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "2016-09-09 16:56"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "2016-09-09 16:57:30"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
2021-04-15 23:18:05 +03:00
.P
2021-04-13 16:26:54 +03:00
# lvs -o name,time \\
2016-09-12 14:54:37 +03:00
-S 'time since "2016-08-29" && time until "2016-09-09 16:55:12"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time \\
-S 'time since "2016-08-29" && time before "2016-09-09 16:55:12"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Time operators have synonyms: ">=" for since, "<=" for until,
">" for "after" and "<" for "before".
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,time \\
-S 'time >= "2016-08-29" && time <= "2016-09-09 16:55:30"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time \\
-S 'time since "2016-08-29" && time < "2016-09-09 16:55:12"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Example below demonstrates using absolute time expression.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -o name,time --config report/time_format="%s"
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 1473433064
lvol3 1473433008
lvol2 1473432912
lvol1 1472468016
lvol0 1472458517
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since @1473433008'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Examples below demonstrates using freeform time expressions.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvs -o name,time -S 'time since "2 weeks ago"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "1 week ago"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "2 weeks ago"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time before "1 week ago"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "68 hours ago"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs -o name,time -S 'time since "1 year 3 months ago"'
2021-04-13 16:26:54 +03:00
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
2016-09-12 14:54:37 +03:00
.fi
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Command log reporting
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
As described in \fBcategorization based on reporting facility\fP section
2017-03-27 17:45:48 +03:00
at the beginning of this document, both \fBreport-oriented\fP and
\fBprocessing-oriented\fP LVM commands can report the command log if
2016-09-12 14:54:37 +03:00
this is enabled with \fBlog/report_command_log\fP configuration setting.
Just like any other report, we can set the set of fields to display
(\fBlog/command_log_cols\fP) and to sort by (\fBlog/command_log_sort\fP)
for this report.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full log/report_command_log log/command_log_cols \\
2016-09-12 14:54:37 +03:00
log/command_log_sort log/command_log_selection
report_command_log=1
command_log_cols="log_seq_num,log_type,log_context,log_object_type,
log_object_name,log_object_group,log_message,
log_errno,log_ret_code"
command_log_sort="log_seq_num"
command_log_selection="!(log_type=status && message=success)"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
Logical Volume
==============
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
As you can see, the command log is empty (it contains only field names).
By default, LVM uses selection on the command log report and this case
no row matched the selection criteria, see also \fBlog report specifics\fP
section in this document for more information. We're displaying complete
log report in the example below where we can see that both LVs lvol0 and
lvol1 were successfully processed as well as the VG vg they are part of.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvmconfig --type full log/command_log_selection
2016-09-12 14:54:37 +03:00
command_log_selection="all"
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvs
Logical Volume
==============
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
3 status processing vg vg success 0 1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
# lvchange -an vg/lvol1
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol1 vg success 0 1
2 status processing vg vg success 0 1
.fi
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Handling multiple reports per single command
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
To configure the log report directly on command line, we need to use
2021-04-15 23:18:05 +03:00
\fB--configreport\fP option before we start any
.BR -o | --options ,
.BR -O | --sort
or
.BR -S | --select
that is targeted for log report.
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -o lv_name,lv_size --configreport log -o log_object_type, \\
2016-09-12 14:54:37 +03:00
log_object_name,log_message,log_ret_code
Logical Volume
==============
LV LSize
lvol1 4.00m
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Command Log
===========
ObjType ObjName Msg RetCode
lv lvol0 success 1
lv lvol1 success 1
vg vg success 1
.fi
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
The \fBlvm fullreport\fP, with or without log report, consists of several
2017-03-27 17:45:48 +03:00
reports - the \fB--configreport\fP is also used to target particular
2016-09-12 14:54:37 +03:00
subreport here.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Below is an extended example with \fBlvm fullreport\fP to illustrate
combination of various options. The report output is in JSON format.
Also, we configure "vg", "pvseg", "seg" and "log" subreport to contain
2020-10-03 14:52:37 +03:00
only specified fields. For the "pvseg" subreport, we're interested only
2016-09-12 14:54:37 +03:00
in PV names having "sda" in their name. For the "log" subreport we're
2020-10-03 14:52:37 +03:00
interested only in log lines related to either "lvol0" object or object
2016-09-12 14:54:37 +03:00
having "sda" in its name. Also, for the log subreport we define ordering
to be based on "log_object_type" field.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
2017-03-27 17:45:48 +03:00
# lvm fullreport --reportformat json \\
--configreport vg -o vg_name,vg_size \\
--configreport pvseg -o pv_name,pvseg_start \\
2016-09-12 14:54:37 +03:00
-S 'pv_name=~sda' \\
2017-03-27 17:45:48 +03:00
--configreport seg -o lv_name,seg_start \\
--configreport log -o log_object_type,log_object_name \\
2016-09-12 14:54:37 +03:00
-O log_object_type \\
-S 'log_object_name=lvol0 || \\
log_object_name=~sda'
{
"report": [
{
"vg": [
{"vg_name":"vg", "vg_size":"200.00m"}
]
,
"pv": [
{"pv_name":"/dev/sda", "vg_name":"vg"},
{"pv_name":"/dev/sdb", "vg_name":"vg"}
]
,
"lv": [
{"lv_name":"lvol0", "vg_name":"vg"},
{"lv_name":"lvol1", "vg_name":"vg"}
]
,
"pvseg": [
{"pv_name":"/dev/sda", "pvseg_start":"0"},
{"pv_name":"/dev/sda", "pvseg_start":"1"},
{"pv_name":"/dev/sda", "pvseg_start":"2"},
{"pv_name":"/dev/sda", "pvseg_start":"3"}
]
,
"seg": [
{"lv_name":"lvol0", "seg_start":"0 "},
{"lv_name":"lvol1", "seg_start":"0 "}
]
}
]
,
"log": [
{"log_object_type":"lv", "log_object_name":"lvol0"},
{"log_object_type":"lv", "log_object_name":"lvol0"},
{"log_object_type":"pv", "log_object_name":"/dev/sda"},
{"log_object_type":"pv", "log_object_name":"/dev/sda"},
]
}
.fi
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SS Report extensions for LVM shell
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
As already stated in \fBlog report coverage\fP paragraph under
\fBlog report specifics\fP in this documentation, when using \fBLVM shell\fP
the \fBlog report\fP coverage is wider. There's also special command
designed to query last command's log report in the \fBLVM shell\fP -
the \fBlastlog\fP command.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
The example below illustrates a situation where we called lvs command.
After that, we inspected the log report with the \fBlastlog\fP, without
any selection so all the log report is displayed on output. Then we called
\fBlastlog\fP further, giving various selection criteria. Then we ran
unknown LVM command "abc" for which the log report displays appropriate
failure state.
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
.nf
# lvm
lvm> lvs
Logical Volume
==============
LV LSize Cpy%Sync
2021-04-13 16:26:54 +03:00
lvol1 4.00m 100.00
lvol0 4.00m
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
3 status processing vg vg success 0 1
4 status shell cmd lvs success 0 1
2021-04-15 23:18:05 +03:00
.P
2021-04-13 16:26:54 +03:00
lvm> lastlog
2016-09-12 14:54:37 +03:00
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
3 status processing vg vg success 0 1
4 status shell cmd lvs success 0 1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
lvm> lastlog -S log_object_type=lv
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
lvm> lastlog -S log_context=shell
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
4 status shell cmd lvs success 0 1
2021-04-15 23:18:05 +03:00
.P
2016-09-12 14:54:37 +03:00
lvm> abc
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 error shell cmd abc No such command 'abc'. Try 'help'. -1 0
2 status shell cmd abc failure -1 2
.fi
2021-04-15 23:18:05 +03:00
.
2016-09-12 14:54:37 +03:00
.SH SEE ALSO
2021-04-15 23:18:05 +03:00
.
2021-04-11 22:11:02 +03:00
.BR lvm (8),
.BR lvmconfig (8),
2021-04-15 23:18:05 +03:00
.BR "lvm fullreport" (8),
.BR lvcreate (8),
.br
.BR lvs (8),
.BR pvs (8),
.BR vgs (8),
.P
.BR date (1),
.BR strftime (3)