1LVMREPORT(7)                                                      LVMREPORT(7)
2
3
4

NAME

6       lvmreport — LVM reporting and related features
7

DESCRIPTION

9       LVM uses single reporting infrastructure that sets standard on LVM com‐
10       mand's output and it provides wide range of configuration settings  and
11       command  line  options to customize report and filter the report's out‐
12       put.
13

USAGE

15   Categorization based on reporting facility
16       Based on functionality, commands which make use of the reporting infra‐
17       structure are divided in two groups:
18
19       Report-oriented commands
20              These  commands inform about current LVM state and their primary
21              role is to display this information in compendious way. To  make
22              a  distinction, we will name this report as main report. The set
23              of report-only  commands  include:  pvs,  vgs,  lvs,  pvdisplay,
24              vgdisplay, lvdisplay, lvm devtypes, lvm fullreport.  For further
25              information about main report, see Main report specifics.
26
27       Processing-oriented commands
28              These commands are responsible for changing LVM state  and  they
29              do not contain any main report as identified for report-oriented
30              commands, they only perform some kind of processing. The set  of
31              processing-oriented   commands   includes:  pvcreate,  vgcreate,
32              lvcreate,  pvchange,  vgchange,  lvchange,  pvremove,  vgremove,
33              lvremove,  pvresize,  vgextend,  vgreduce,  lvextend,  lvreduce,
34              lvresize, lvrename, pvscan, vgscan, lvscan, pvmove, vgcfgbackup,
35              vgck, vgconvert, vgexport, vgimport, vgmknodes.
36
37       If  enabled,  so called log report is either displayed solely (for pro‐
38       cessing-oriented commands) or in addition to main report  (for  report-
39       oriented  commands).  The log report contains a log of operations, mes‐
40       sages and per-object status with complete  object  identification  col‐
41       lected  during LVM command execution. See Log report specifics for more
42       information about this report type.
43
44   Terms
45       When describing reporting functionality and features in this  text,  we
46       will use terms row and column. By row we mean series of values reported
47       for single entity (for example single PV, VG or LV).  Each  value  from
48       the row then belongs to a column of certain type. The columns have col‐
49       umn headings which are short descriptions for the columns. The  columns
50       are  referenced by column names. Please note that this text is also us‐
51       ing term field interchangeably with the term column. Most of  the  time
52       the term columns is abbreviated as col in configuration.
53
54   Common report configuration settings and command line options
55       There  are common configuration settings and command line options which
56       apply to both main report and log report. Following lists  contain  all
57       of them, separated into groups based on their use.
58
59   Common configuration settings
60       Changing report output format, composition and other output modifiers:
61              - global/suffix
62              - global/units
63              - report/aligned
64              - report/binary_values_as_numeric
65              - report/columns_as_rows
66              - report/compact_output
67              - report/compact_output_cols
68              - report/headings
69              - report/list_item_separator
70              - report/mark_hidden_devices
71              - report/output_format
72              - report/prefixes
73              - report/quoted
74              - report/separator
75              - report/time_format
76              - report/two_word_unknown_device
77
78       Special settings
79              - report/buffered
80
81       This  document does not describe these settings in more detail - if you
82       need detailed information, including values which are accepted for  the
83       settings, please run lvmconfig --type default --withcomments <setting>.
84       There are more configuration settings in addition  to  the  common  set
85       listed  above,  but  they are specific to either main report or log re‐
86       port, see main report specifics and log report specifics for these set‐
87       tings. Besides configuring reports globally by using configuration set‐
88       tings, there are also command line options you can use to extend, over‐
89       ride or further specify the report configuration.
90
91   Common command line options
92       Definition of the set of fields to use
93
94              -o|--options FieldSet
95                     Field  set  to use. See main report specifics and log re‐
96                     port specifics for information about field  sets  config‐
97                     ured  with global configuration settings that this option
98                     overrides.
99
100              -o|--options +FieldSet
101                     Fields to include to current field set. See  main  report
102                     specifics and  log report specifics for information about
103                     field sets configured with global configuration  settings
104                     that this option extends.
105
106              -o|--options -FieldSet
107                     Fields to exclude from current field set. See main report
108                     specifics and log report specifics for information  about
109                     field  sets configured with global configuration settings
110                     that this option reduces.
111
112              -o|--options #FieldSet
113                     Compaction  of  unused  fields.   Overrides   report/com‐
114                     pact_output_cols configuration setting.
115
116       Sorting
117
118              -O|--sort +FieldSet
119                     Fields  to  sort  by  in ascending order. See main report
120                     specifics and log report specifics for information  about
121                     field  sets configured with global configuration settings
122                     that this option overrides.
123
124              -O|--sort -FieldSet
125                     Fields to sort by in descending order.  See  main  report
126                     specifics  and log report specifics for information about
127                     fields sets configured with global configuration settings
128                     that this options overrides.
129
130       Selection
131
132              -S|--select Selection
133                     Define  selection criteria for report output. For log re‐
134                     port, this also overrides log/command_log_selection  con‐
135                     figuration setting, see also log report specifics.
136
137       Changing output format and composition
138
139              --reportformat
140                     Overrides report/output_format configuration setting.
141
142              --aligned
143                     Overrides report/aligned configuration setting.
144
145              --binary
146                     Overrides  report/binary_values_as_numeric  configuration
147                     setting.
148
149              --nameprefixes
150                     Overrides report/prefixes configuration setting.
151
152              --noheadings
153                     Overrides report/noheadings configuration setting.
154
155              --nosuffix
156                     Overrides global/suffix configuration setting.
157
158              --rows Overrides report/columns_as_rows configuration setting.
159
160              --separator
161                     Overrides report/separator configuration setting.
162
163              --units
164                     Overrides global/units configuration setting.
165
166              --unquoted
167                     Overrides report/quoted configuration setting.
168
169       Special options
170
171              --configreport ReportName
172                     This defines the  ReportName  for  which  any  subsequent
173                     -o|--columns,  -O|--sort  or  -S|--select applies to. See
174                     also Main report specifics and Log report  specifics  for
175                     possible ReportName values.
176
177              --logonly
178                     When an LVM command contains both main report and log re‐
179                     port, this option suppresses the main report  output  and
180                     it causes the log report output to be displayed only.
181
182              --unbuffered
183                     Overrides report/buffered configuration setting.
184
185       The FieldSet mentioned in the lists above is a set of field names where
186       each field name is delimited by "," character.  Field  set  definition,
187       sorting  and  selection  may  be  repeated on command line (-o+/-o- in‐
188       cludes/excludes fields to/from current list, for all the other  repeat‐
189       able  options,  the last value typed for the option on the command line
190       is used). The Selection is a string with selection criteria,  see  also
191       Selection paragraph below for more information about constructing these
192       criteria.
193
194   Main report specifics
195       The main report currently encompasses these distinct  subtypes,  refer‐
196       enced by their name - ReportName as listed below. The command in paren‐
197       thesis is representative command that uses the main report  subtype  by
198       default.   Each  subtype  has  its own configuration setting for global
199       field set definition as well as sort  field  definition  (listed  below
200       each individual ReportName):
201
202              pv     representing report about Physical Volumes (pvs)
203                     - report/pvs_cols
204                     - report/pvs_sort
205
206              pvseg  representing report about Physical Volume Segments
207                     (pvs --segments)
208                     - report/pvseg_cols
209                     - report/pvseg_sort
210
211              vg     representing report about Volume Groups (vgs)
212                     - report/vgs_cols
213                     - report/vgs_sort
214
215              lv     representing report about Logical Volumes (lvs)
216                     - report/lvs_cols
217                     - report/lvs_sort
218
219              seg    representing report about Logical Volume Segments
220                     (lvs --segments)
221                     - report/segs_cols
222                     - report/segs_sort
223
224              full   representing report combining all of the above as a whole
225                     (lvm fullreport)
226                     - report/pvs_cols_full
227                     - report/pvs_sort_full
228                     - report/pvsegs_cols_full
229                     - report/pvseg_sort_full
230                     - report/vgs_cols_full
231                     - report/vgs_sort_full
232                     - report/lvs_cols_full
233                     - report/lvs_sort_full
234                     - report/segs_cols_full
235                     - report/segs_sort_full
236
237              devtype
238                     representing report about device types (lvm devtypes)
239                     - report/devtypes_cols
240                     - report/devtypes_sort
241
242       Use pvs, vgs, lvs -o help or lvm devtypes -o help to get complete  list
243       of  fields  that you can use for main report. The list of fields in the
244       help output is separated in groups based on which report type they  be‐
245       long  to.   Note  that  LVM can change final report type used if fields
246       from different groups are combined together. Some of these combinations
247       are not allowed in which case LVM will issue an error.
248
249       For  all  main  report  subtypes except full, it's not necessary to use
250       --configreport ReportName to denote which report any subsequent -o,  -O
251       or  -S option applies to as they always apply to the single main report
252       type. Currently, lvm fullreport is the only command that includes  more
253       than one main report subtype. Therefore, the --configreport is particu‐
254       larly suitable for the full report if you need to configure each of its
255       subreports in a different way.
256
257   Log report specifics
258       You  can  enable  log  report with log/report_command_log configuration
259       setting - this functionality is disabled by  default.  The  log  report
260       contains  a log collected during LVM command execution and then the log
261       is displayed just like any other report known from main  report.  There
262       is  only  one  log  report subtype as shown below together with related
263       configuration settings for fields, sorting and selection:
264
265              log    representing log report
266                     - log/command_log_cols
267                     - log/command_log_sort
268                     - log/command_log_selection
269
270       You always need to use --configreport log together  with  -o|--options,
271       -O|--sort or -S|--selection to override configuration settings directly
272       on command line for log report. When compared to main report, in  addi‐
273       tion to usual configuration settings for report fields and sorting, the
274       log report has also configuration option for  selection  -  report/com‐
275       mand_log_selection.  This  configuration setting is provided for conve‐
276       nience so it's not necessary to use -S|--select on  command  line  each
277       time an LVM command is executed and we need the same selection criteria
278       to be applied for log report. Default selection criteria used  for  log
279       report are log/command_log_selection="!(log_type=status && message=suc‐
280       cess)".  This means that, by default, log report doesn't display status
281       messages  about successful operation and it displays only rows with er‐
282       ror, warning, print-type messages and  messages  about  failure  states
283       (for more information, see log report content below).
284
285       Log report coverage
286       Currently,  when  running LVM commands directly (not in LVM shell), the
287       log report covers command's processing stage which is the  moment  when
288       LVM  entities  are iterated and processed one by one. It does not cover
289       any command initialization nor command finalization stage. If there  is
290       any  message  issued  out  of log report's coverage range, such message
291       goes directly to output, bypassing the log report. By default, that  is
292       standard  error output for error and warning messages and standard out‐
293       put for common print-like messages.
294
295       When running LVM commands in LVM shell, the log report covers the whole
296       LVM command's execution, including command's processing as well as ini‐
297       tialization and finalization stage. So from this point of view, the log
298       report  coverage is complete for executed LVM commands. Note that there
299       are still a few moments when LVM shell needs to initialize  itself  be‐
300       fore  it  even  enters the main loop in which it executes LVM commands.
301       Also, there is a moment when LVM shell  needs  to  prepare  log  report
302       properly  for  next  command  executed in the shell and then, after the
303       command's run, the shell needs to display the log report for  that  re‐
304       cently executed command. If there is a failure or any other message is‐
305       sued during this time, the LVM will bypass log report and display  mes‐
306       sages on output directly.
307
308       For these reasons and for completeness, it's not possible to rely fully
309       on log report as the only indicator of LVM command's status and the on‐
310       ly  place  where  all  messages issued during LVM command execution are
311       collected.  You always need to check whether the command has not failed
312       out of log report's range by checking the non-report output too.
313
314       To  help with this, LVM can separate output which you can then redirect
315       to any custom file descriptor that you prepare before  running  an  LVM
316       command  or  LVM shell and then you make LVM to use these file descrip‐
317       tors for different kinds of output by  defining  environment  variables
318       with  file  descriptor  numbers.  See  also  LVM_OUT_FD, LVM_ERR_FD and
319       LVM_REPORT_FD environment variable description in lvm(8) man page.
320
321       Also note that, by default, reports use the  same  file  descriptor  as
322       common  print-like  messages,  which is standard output. If you plan to
323       use log report in your scripts or any external  tool,  you  should  use
324       LVM_OUT_FD,  LVM_ERR_FD  and LVM_REPORT_FD to separate all output types
325       to different file descriptors. For example, with bash, that would be:
326
327              LVM_OUT_FD=3   LVM_ERR_FD=4   LVM_REPORT_FD=5   <lvm    command>
328              3>out_file 4>err_file 5>report_file
329
330       Where the <lvm_command> is either direct LVM command or LVM shell.  You
331       can collect all three types of output in particular files then.
332
333       Log report content
334
335       Each item in the log report consists of these set of  fields  providing
336       various information:
337
338       Basic information (mandatory):
339
340              log_seq_num
341                     Item  sequence  number. The sequence number is unique for
342                     each log item and it increases in the order  of  the  log
343                     items as they appeared during LVM command execution.
344
345              log_type
346                     Type  of  log  for  the  item. Currently, these types are
347                     used:
348
349                     status for any status information that is logged
350
351                     print  for any common message printed while  the  log  is
352                            collected
353
354                     error  for  any  error  message  printed while the log is
355                            collected
356
357                     warn   for any warning message printed while the  log  is
358                            collected
359
360              log_context
361                     Context  of the log for the item. Currently, two contexts
362                     are identified:
363
364                     shell  for the log collected in the outermost code before
365                            and after executing concrete LVM commands
366
367                     processing
368                            for  the  log collected while processing LVM enti‐
369                            ties during LVM command execution
370
371       Message (mandatory):
372
373              log_message
374                     Any message associated with current item. For status  log
375                     type,  the message contains either success or failure de‐
376                     noting current state.  For  print,  error  and  warn  log
377                     types,  the  message  contains  the exact message of that
378                     type that got issued.
379
380       Object information (used only if applicable):
381
382              log_object_type field
383                     Type of the object  processed.  Currently,  these  object
384                     types are recognized:
385
386                     cmd    for command as a whole
387
388                     orphan for processing group of PVs not in any VG yet
389
390                     pv     for PV processing
391
392                     label  for direct PV label processing (without VG metada‐
393                            ta)
394
395                     vg     for VG processing
396
397                     lv     for LV processing
398
399              log_object_name
400                     Name of the object processed.
401
402              log_object_id
403                     ID of the object processed.
404
405              log_object_group
406                     A group where the processed object belongs to.
407
408              log_object_group_id
409                     An ID of a group where the processed object belongs to.
410
411       Numeric status (used only if applicable):
412
413              log_errno
414                     Error number associated with current item.
415
416              log_ret_code
417                     Return code associated with current item.
418
419       You can also run lvm --configreport log -o help to to display  complete
420       list of fields that you may use for the log report.
421
422   Selection
423       Selection  is  used for a report to display only rows that match selec‐
424       tion criteria. All rows are  displayed  with  the  additional  selected
425       field (-o selected) displaying 1 if the row matches the Selection and 0
426       otherwise. The selection criteria are a set of statements  combined  by
427       logical and grouping operators.  The statement consists of a field name
428       for which a set of valid values is defined using comparison  operators.
429       For  complete  list  of fields names that you can use in selection, see
430       the output of lvm -S help. The help output also contains type of values
431       that each field displays enclosed in brackets.
432
433       List of operators recognized in selection criteria
434
435              Comparison operators (cmp_op)
436                     =~     matching regular expression.
437                     !~     not matching regular expression.
438                     =      equal to.
439                     !=     not equal to.
440                     >=     greater than or equal to.
441                     >      greater than
442                     <=     less than or equal to.
443                     <      less than.
444
445              Binary logical operators (cmp_log)
446                     &&     all fields must match
447                     ,      all fields must match
448                     ||     at least one field must match
449                     #      at least one field must match
450
451              Unary logical operators
452                     !      logical negation
453
454              Grouping operators
455                     (      left parenthesis
456                     )      right parenthesis
457                     [      list start
458                     ]      list end
459                     {      list subset start
460                     }      list subset end
461
462       Field types and selection operands
463
464       Field  type  restricts the set of operators and values that you may use
465       with the field when defining selection criteria. You can see field type
466       for  each field if you run lvm -S help where you can find the type name
467       enclosed in square brackets.  Currently,  LVM  recognizes  these  field
468       types in reports:
469
470              string for  set  of  characters (for each string field type, you
471                     can use either string or regular expression -  regex  for
472                     the value used in selection criteria)
473
474              string list
475                     for set of strings
476
477              number for integer value
478
479              size   for  integer or floating point number with size unit suf‐
480                     fix (see also lvcreate(8) man page  and  description  for
481                     "-L|--size" option for the list of recognized suffixes)
482
483              percent for floating point number with or without % suffix
484                     (e.g. 50 or 50%)
485
486              time   for time values
487
488       When  using  string  list in selection criteria, there are several ways
489       how LVM can match string list fields from  report,  depending  on  what
490       list  grouping  operator is used and what item separator is used within
491       that set of items. Also, note that order of items does not matter here.
492
493matching the set strictly where all items must match - use [ ], e.g.
494          ["a","b","c"]
495
496matching  a subset of the set - use { } with "," or "&&" as item de‐
497          limiter, e.g. {"a","b","c"}
498
499matching an intersection with the set - use { } with "#" or "||"  as
500          item delimiter, e.g. {"a" || "b" || "c"}
501
502       When  using  time in your selection criteria, LVM can recognize various
503       time formats using standard, absolute or freeform expressions. For  ex‐
504       amples  demonstrating time expressions in selection criteria, see EXAM‐
505       PLES section.
506
507Standard time format
508
509          -  date
510                    YYYY-MM-DD
511                    YYYY-MM, auto DD=1
512                    YYYY, auto MM=01 and DD=01
513
514          -  time
515                    hh:mm:ss
516                    hh:mm, auto ss=0
517                    hh, auto mm=0, auto ss=0
518
519          -  timezone
520                    +hh:mm or -hh:mm
521                    +hh or -hh
522
523          The full date/time specification is YYYY-MM-DD hh:mm:ss.  Users  are
524          able  to  leave  date/time  parts from right to left. Whenever these
525          parts are left out, a range is  assumed  automatically  with  second
526          granularity. For example:
527
528          "2015-07-07 9:51" means range of "2015-07-07 9:51:00" - "2015-07-07 9:51:59"
529          "2015-07" means range of "2015-07-01 0:00:00" - "2015-07-31 23:59:59"
530          "2015" means range of "2015-01-01 0:00:00" - "2015-12-31 23:59:59"
531
532Absolute time format
533          Absolute  time  is  defined  as  number  of  seconds since the Epoch
534          (1970:01:01 00:00 +00:00).
535
536          -  @seconds
537
538Freeform time format
539          -  weekday names ("Sunday" - "Saturday" or abbreviated  as  "Sun"  -
540             "Sat")
541          -  labels for points in time ("noon", "midnight")
542          -  labels for a day relative to current day ("today", "yesterday")
543          -  points  back in time with relative offset from today (N is a num‐
544             ber)
545                    "N" "seconds" / "minutes" / "hours" / "days" /  "weeks"  /
546                    "years" "ago"
547                    "N" "secs" / "mins" / "hrs" ... "ago"
548                    "N" "s" / "m" / "h" ... "ago"
549          -  time  specification  either in hh:mm:ss format or with AM/PM suf‐
550             fixes
551          -  month names ("January" - "December" or  abbreviated  as  "Jan"  -
552             "Dec")
553
554       Informal grammar specification
555
556       - STATEMENT  =  column  cmp_op  VALUE  |  STATEMENT  log_op STATEMENT |
557         (STATEMENT) | !(STATEMENT)
558
559       - VALUE = [VALUE log_op VALUE]
560         For list-based types: string list. Matches strictly.  The log_op must
561         always be of one type within the whole list value.
562
563       - VALUE = {VALUE log_op VALUE}
564         For list-based types: string list. Matches a subset.  The log_op must
565         always be of one type within the whole list value.
566
567       - VALUE = value
568         For scalar types: number, size, percent, string (or string regex).
569

EXAMPLES

571   Basic usage
572       We start our examples with  default  configuration  -  lvmconfig(8)  is
573       helpful  command  to display configuration settings which are currently
574       used, including all configuration related to reporting. We will use  it
575       throughout examples below to display current configuration.
576
577       # lvmconfig --type full global/units global/suffix \
578          report/output_format  report/compact_output \
579          report/compact_output_cols report/aligned \
580          report/headings report/separator \
581          report/list_item_separator report/prefixes \
582          report/quoted report/columns_as_rows \
583          report/binary_values_as_numeric report/time_format \
584          report/mark_hidden_devices report/two_word_unknown_device \
585          report/buffered
586       units="h"
587       suffix=1
588       output_format="basic"
589       compact_output=0
590       compact_output_cols=""
591       aligned=1
592       headings=1
593       separator=" "
594       list_item_separator=","
595       prefixes=0
596       quoted=1
597       columns_as_rows=0
598       binary_values_as_numeric=0
599       time_format="%Y-%m-%d %T %z"
600       mark_hidden_devices=1
601       two_word_unknown_device=0
602       buffered=1
603
604       Also,  we  start  with  simple  LVM  layout  with  two  PVs  (/dev/sda,
605       /dev/sdb), VG (vg) and two LVs (lvol0 and lvol1) in the VG. We  display
606       all  possible reports as single commands here, see also pvs(8), vgs(8),
607       lvs(8) man pages for more information. The field set  for  each  report
608       type  is configured with configuration settings as we already mentioned
609       in main report specifics section in this man page.
610
611       # lvmconfig --type full report/pvs_cols report/pvs_sort \
612          report/pvsegs_cols report/pvsegs_sort report/vgs_cols \
613          report/vgs_sort report/lvs_cols report/lvs_sort \
614          report/segs_cols report/segs_sort
615       pvs_cols="pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
616       pvs_sort="pv_name"
617       pvsegs_cols="pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,
618                    pvseg_start,pvseg_size"
619       pvsegs_sort="pv_name,pvseg_start"
620       vgs_cols="vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
621       vgs_sort="vg_name"
622       lvs_cols="lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,move_pv,
623                 mirror_log,copy_percent,convert_lv"
624       lvs_sort="vg_name,lv_name"
625       segs_cols="lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
626       segs_sort="vg_name,lv_name,seg_start"
627
628       # pvs
629         PV         VG Fmt  Attr PSize   PFree
630         /dev/sda   vg lvm2 a--  100.00m 88.00m
631         /dev/sdb   vg lvm2 a--  100.00m 92.00m
632
633       # pvs --segments
634         PV         VG Fmt  Attr PSize   PFree  Start SSize
635         /dev/sda   vg lvm2 a--  100.00m 88.00m     0     1
636         /dev/sda   vg lvm2 a--  100.00m 88.00m     1     1
637         /dev/sda   vg lvm2 a--  100.00m 88.00m     2     1
638         /dev/sda   vg lvm2 a--  100.00m 88.00m     3    22
639         /dev/sdb   vg lvm2 a--  100.00m 92.00m     0     1
640         /dev/sdb   vg lvm2 a--  100.00m 92.00m     1     1
641         /dev/sdb   vg lvm2 a--  100.00m 92.00m     2    23
642
643       # vgs
644         VG #PV #LV #SN Attr   VSize   VFree
645         vg   2   2   0 wz--n- 200.00m 180.00m
646
647       # lvs
648         LV    VG Attr       LSize Pool Origin Move Log Cpy%Sync Convert
649         lvol0 vg -wi-a----- 4.00m
650         lvol1 vg rwi-a-r--- 4.00m                      100.00
651
652       # lvs --segments
653         LV    VG Attr       #Str Type   SSize
654         lvol0 vg -wi-a-----    1 linear 4.00m
655         lvol1 vg rwi-a-r---    2 raid1  4.00m
656
657       We will use report/lvs_cols and report/lvs_sort configuration  settings
658       to  define our own list of fields to use and to sort by that is differ‐
659       ent from defaults. You can do this for other  reports  in  same  manner
660       with   report/{pvs,pvseg,vgs,seg}_{cols,sort}  configuration  settings.
661       Also note that in the example below, we  don't  display  the  "lv_time"
662       field even though we're using it for sorting - this is allowed.
663
664       # lvmconfig --type full report/lvs_cols report/lvs_sort
665       lvs_cols="lv_name,lv_size,origin,pool_lv,copy_percent"
666       lvs_sort="-lv_time"
667
668       # lvs
669         LV    LSize Origin Pool Cpy%Sync
670         lvol1 4.00m             100.00
671         lvol0 4.00m
672
673       You  can  use -o|--options command line option to override current con‐
674       figuration directly on command line.
675
676       # lvs -o lv_name,lv_size
677         LV    LSize
678         lvol1 4.00m
679         lvol0 4.00m
680
681       # lvs -o+lv_layout
682         LV    LSize Origin Pool Cpy%Sync Layout
683         lvol1 4.00m             100.00   raid,raid1
684         lvol0 4.00m                      linear
685
686       # lvs -o-origin
687         LV    LSize Pool Cpy%Sync
688         lvol1 4.00m      100.00
689         lvol0 4.00m
690
691       # lvs -o lv_name,lv_size,origin -o+lv_layout -o-origin -O lv_name
692         LV    LSize Layout
693         lvol0 4.00m linear
694         lvol1 4.00m raid,raid1
695
696       You can obtain the same information with single command where  all  the
697       information  about  PVs,  PV segments, LVs and LV segments are obtained
698       per VG under a single VG lock for consistency,  see  also  lvm  fullre‐
699       port(8)  man page for more information. The fullreport has its own con‐
700       figuration settings to define field sets to use, similar to  individual
701       reports  as  displayed  above,  but configuration settings have "_full"
702       suffix now.  This way, it's possible to  configure  different  sets  of
703       fields  to display and to sort by for individual reports as well as the
704       full report.
705
706       # lvmconfig --type full report/pvs_cols_full \
707          report/pvs_sort_full report/pvsegs_cols_full \
708          report/pvsegs_sort_full report/vgs_cols_full \
709          report/vgs_sort_full report/lvs_cols_full \
710          report/lvs_sort_full report/segs_cols_full \
711          report/segs_sort_full
712       pvs_cols_full="pv_name,vg_name"
713       pvs_sort_full="pv_name"
714       pvsegs_cols_full="pv_name,pvseg_start,pvseg_size"
715       pvsegs_sort_full="pv_uuid,pvseg_start"
716       vgs_cols_full="vg_name"
717       vgs_sort_full="vg_name"
718       lvs_cols_full="lv_name,vg_name"
719       lvs_sort_full="vg_name,lv_name"
720       segs_cols_full="lv_name,seg_start,seg_size"
721       segs_sort_full="lv_uuid,seg_start"
722
723       # lvm fullreport
724         VG
725         vg
726         PV         VG
727         /dev/sda   vg
728         /dev/sdb   vg
729         LV    VG
730         lvol0 vg
731         lvol1 vg
732         PV         Start SSize
733         /dev/sda       0     1
734         /dev/sda       1     1
735         /dev/sda       2     1
736         /dev/sda       3    22
737         /dev/sdb       0     1
738         /dev/sdb       1     1
739         /dev/sdb       2    23
740         LV    Start SSize
741         lvol0    0  4.00m
742         lvol1    0  4.00m
743
744   Automatic output compaction
745       If you look at the lvs output above, you can see that the  report  also
746       contains  fields for which there is no information to display (e.g. the
747       columns under "Origin" and "Pool" heading - the "origin" and  "pool_lv"
748       fields). LVM can automatically compact report output so such fields are
749       not included in final output. To enable this feature and to compact all
750       fields, use report/compact_output=1 in your configuration.
751
752       # lvmconfig --type full report/compact_output
753       compact_output=1
754
755       # lvs
756         LV    LSize Cpy%Sync
757         lvol1 4.00m 100.00
758         lvol0 4.00m
759
760       # lvs vg/lvol0
761         LV    LSize
762         lvol0 4.00m
763
764       Alternatively,  you can define which fields should be compacted by con‐
765       figuring report/compact_output_cols configuration setting (or  -o|--op‐
766       tions # command line option).
767
768       # lvmconfig --type full report/compact_output report/compact_output_cols
769       compact_output=0
770       compact_output_cols="origin"
771
772       # lvs
773         LV    LSize Pool Cpy%Sync
774         lvol1 4.00m      100.00
775         lvol0 4.00m
776
777       # lvs vg/lvol0
778         LV    LSize Pool
779         lvol0 4.00m
780
781       # lvs -o#pool_lv
782         LV    LSize Origin Cpy%Sync
783         lvol1 4.00m        100.00
784         lvol0 4.00m
785
786       We will use report/compact_output=1 for subsequent examples.
787
788   Further formatting options
789       By  default, LVM displays sizes in reports in human-readable form which
790       means that the most suitable unit is used so it's easy to read. You can
791       use  report/units  configuration setting (or --units option directly on
792       command line) and report/suffix configuration  setting  (or  --nosuffix
793       command line option) to change this.
794
795       # lvs --units b --nosuffix
796         LV    LSize   Cpy%Sync
797         lvol1 4194304 100.00
798         lvol0 4194304
799
800       If  you want to configure whether report headings are displayed or not,
801       use report/headings configuration  settings  (or  --noheadings  command
802       line option).
803
804       # lvs --noheadings
805         lvol1 4.00m 100.00
806         lvol0 4.00m
807
808       In  some cases, it may be useful to display report content as key=value
809       pairs where key here is actually the field  name.  Use  report/prefixes
810       configuration setting (or --nameprefixes command line option) to switch
811       between standard output and the key=value output. The key=value pair is
812       the  output  that is suitable for use in scripts and for other tools to
813       parse easily.  Usually, you also don't want to  display  headings  with
814       the output that has these key=value pairs.
815
816       # lvs --noheadings --nameprefixes
817         LVM2_LV_NAME='lvol1' LVM2_LV_SIZE='4.00m' LVM2_COPY_PERCENT='100.00'
818         LVM2_LV_NAME='lvol0' LVM2_LV_SIZE='4.00m' LVM2_COPY_PERCENT=''
819
820       To  define whether quotation marks in key=value pairs should be used or
821       not, use report/quoted configuration  setting  (or  --unquoted  command
822       line option).
823
824       # lvs --noheadings --nameprefixes --unquoted
825         LVM2_LV_NAME=lvol1 LVM2_LV_SIZE=4.00m LVM2_COPY_PERCENT=100.00
826         LVM2_LV_NAME=lvol0 LVM2_LV_SIZE=4.00m LVM2_COPY_PERCENT=
827
828       For  easier  parsing,  you can even transpose the report so each column
829       now becomes a  row  in  the  output.  This  is  done  with  report/out‐
830       put_as_rows configuration setting (or --rows command line option).
831
832       # lvs --noheadings --nameprefixes --unquoted --rows
833         LVM2_LV_NAME=lvol1 LVM2_LV_NAME=lvol0
834         LVM2_LV_SIZE=4.00m LVM2_LV_SIZE=4.00m
835         LVM2_COPY_PERCENT=100.00 LVM2_COPY_PERCENT=
836
837       Use report/separator configuration setting (or --separator command line
838       option) to define your own field separator to use.
839
840       # lvs --noheadings --nameprefixes --unquoted --separator " | "
841         LVM2_LV_NAME=lvol1 | LVM2_LV_SIZE=4.00m | LVM2_COPY_PERCENT=100.00
842         LVM2_LV_NAME=lvol0 | LVM2_LV_SIZE=4.00m | LVM2_COPY_PERCENT=
843
844       If you are using your own separator, the columns in the output are  not
845       aligned  by  default.  Use  report/aligned  configuration  setting  (or
846       --aligned command line option) for LVM to add extra spaces in report to
847       align the output properly.
848
849       # lvs --separator " | "
850         LV | LSize | Cpy%Sync
851         lvol1 | 4.00m | 100.00
852         lvol0 | 4.00m |
853
854       # lvs --separator " | " --aligned
855         LV    | LSize | Cpy%Sync
856         lvol1 | 4.00m | 100.00
857         lvol0 | 4.00m |
858
859       Let's  display  one one more field in addition ("lv_tags" in this exam‐
860       ple) for the lvs report output.
861
862       # lvs -o+lv_tags
863         LV    LSize Cpy%Sync LV Tags
864         lvol1 4.00m 100.00
865         lvol0 4.00m          tagA,tagB
866
867       The "LV Tags" column in the example above  displays  two  list  values,
868       separated  by  ","  character  for LV lvol0. If you need different list
869       item separator, use  report/list_item_separator  configuration  setting
870       its definition.
871
872       # lvmconfig --type full report/list_item_separator
873       list_item_separator=";"
874
875       # lvs -o+tags
876         LV    LSize Cpy%Sync LV Tags
877         lvol1 4.00m 100.00
878         lvol0 4.00m          tagA;tagB
879
880       But  let's still use the original "," character for list_item_separator
881       for subsequent examples.
882
883       Format for any of time values displayed in reports  can  be  configured
884       with report/time_format configuretion setting. By default complete date
885       and time is displayed, including timezone.
886
887       # lvmconfig --type full report/time_format
888       time_format="%Y-%m-%d %T %z"
889
890       # lvs -o+time
891         LV    LSize Cpy%Sync CTime
892         lvol1 4.00m 100.00   2016-08-29 12:53:36 +0200
893         lvol0 4.00m          2016-08-29 10:15:17 +0200
894
895       We can change time format in similar way as we do  when  using  date(1)
896       command  or  strftime(3)  function (lvmconfig --type default --withcom‐
897       ments report/time_format will give you complete list of available  for‐
898       matting options). In the example below, we decided to use %s for number
899       of seconds since Epoch (1970-01-01 UTC).
900
901       # lvmconfig --type full report/time_format
902       time_format="%s"
903
904       # lvs
905         LV    Attr       LSize Cpy%Sync LV Tags   CTime
906         lvol1 rwi-a-r--- 4.00m 100.00             1472468016
907         lvol0 -wi-a----- 4.00m          tagA,tagB 1472458517
908
909       The lvs does not display hidden LVs by default - to include  these  LVs
910       in  the output, you need to use -a|--all command line option. Names for
911       these hidden LVs are displayed within square brackets.
912
913       # lvs -a
914         LV               LSize Cpy%Sync
915         lvol1            4.00m 100.00
916         [lvol1_rimage_0] 4.00m
917         [lvol1_rmeta_0]  4.00m
918         [lvol1_rimage_1] 4.00m
919         [lvol1_rmeta_1]  4.00m
920         lvol0            4.00m
921
922       You can configure LVM to display the square brackets for hidden LVs  or
923       not with report/mark_hidden_devices configuration setting.
924
925       # lvmconfig --type full report/mark_hidden_devices
926       mark_hidden_devices=0
927
928       # lvs -a
929         LV             LSize Cpy%Sync
930         lvol1          4.00m 100.00
931         lvol1_rimage_0 4.00m
932         lvol1_rmeta_0  4.00m
933         lvol1_rimage_1 4.00m
934         lvol1_rmeta_1  4.00m
935         lvol0          4.00m
936
937       It's  not  recommended  to  use  LV  marks for hidden devices to decide
938       whether the LV is the one to use by  end  users  or  not.  Please,  use
939       "lv_role"  field instead which can report whether the LV is "public" or
940       "private". The private LVs are used by LVM only and they should not  be
941       accessed directly by end users.
942
943       # lvs -a -o+lv_role
944         LV             LSize Cpy%Sync Role
945         lvol1          4.00m 100.00   public
946         lvol1_rimage_0 4.00m          private,raid,image
947         lvol1_rmeta_0  4.00m          private,raid,metadata
948         lvol1_rimage_1 4.00m          private,raid,image
949         lvol1_rmeta_1  4.00m          private,raid,metadata
950         lvol0          4.00m          public
951
952       Some of the reporting fields that LVM reports are of binary nature. For
953       such fields, it's either  possible to display  word  representation  of
954       the value (this is used by default) or numeric value (0/1 or -1 in case
955       the value is undefined).
956
957       # lvs -o+lv_active_locally
958         LV    LSize Cpy%Sync ActLocal
959         lvol1 4.00m 100.00   active locally
960         lvol0 4.00m          active locally
961
962       We can change the way how these binary values are  displayed  with  re‐
963       port/binary_values_as_numeric configuration setting.
964
965       # lvmconfig --type full report/binary_values_as_numeric
966       binary_values_as_numeric=1
967
968       # lvs -o+lv_active_locally
969         LV    LSize Cpy%Sync ActLocal
970         lvol1 4.00m 100.00            1
971         lvol0 4.00m                   1
972
973   Changing output format
974       LVM  can output reports in different formats - use report/output_format
975       configuration setting (or --reportformat command line option) to  swith
976       the report output format.
977
978
979       Currently, LVM supports these outpout formats:
980              - "basic" (all the examples we used above used this format),
981              - "json",
982              - "json_std".
983
984       For example:
985       # lvs -o lv_name,lv_size --reportformat json
986         {
987             "report": [
988                 {
989                     "lv": [
990                         {"lv_name":"lvol1", "lv_size":"4.00m"},
991                         {"lv_name":"lvol0", "lv_size":"4.00m"}
992                     ]
993                 }
994             ]
995         }
996
997       The  json_std  output  format  is more compliant with JSON standard and
998       compared to the original json format:
999              - it does not use double quotes around numeric values,
1000              - numeric values are always expressed as numbers,  not  reserved
1001              strings
1002                representing  them  (this  also  means that report/binary_val‐
1003              ues_as_numeric=1
1004                setting is forced)
1005              - it uses 'null' for undefined numeric values,
1006              - it prints string list as proper JSON array of strings  instead
1007              of a single string.
1008
1009       Note  that some configuration settings and command line options have no
1010       effect with certain report formats. For example, with json or  json_std
1011       output,  it doesn't have any meaning to use report/aligned (--aligned),
1012       report/noheadings (--noheadings),  report/columns_as_rows  (--rows)  or
1013       report/buffered  (--unbuffered).  All  these configuration settings and
1014       command line options are ignored if using the json or  json_std  report
1015       output format.
1016
1017   Selection
1018       If you need to select only specific rows from report, you can use LVM's
1019       report selection feature. If you call lvm -S  help,  you'll  get  quick
1020       help  on  selection.  The help contains list of all fields that LVM can
1021       use in reports together with its type enclosed in square brackets.  The
1022       example below contains a line from lvs -S help.
1023
1024       # lvs -S help
1025           ...
1026           lv_size                - Size of LV in current units. [size]
1027           ...
1028
1029       This  line tells you you that the "lv_size" field is of "size" type. If
1030       you look at the bottom of the help output, you can  see  section  about
1031       "Selection operators" and its "Comparison operators".
1032
1033       # lvs -S help
1034        ...
1035       Selection operators
1036       -------------------
1037       Comparison operators:
1038          =~  - Matching regular expression. [regex]
1039          !~  - Not matching regular expression. [regex]
1040           =  - Equal to. [number, size, percent, string, string list, time]
1041          !=  - Not equal to. [number, size, percent, string, string_list, time]
1042          >=  - Greater than or equal to. [number, size, percent, time]
1043           >  - Greater than. [number, size, percent, time]
1044          <=  - Less than or equal to. [number, size, percent, time]
1045           <  - Less than. [number, size, percent, time]
1046       since  - Since specified time (same as '>='). [time]
1047       after  - After specified time (same as '>'). [time]
1048       until  - Until specified time (same as '<='). [time]
1049       before - Before specified time (same as '<'). [time]
1050        ...
1051
1052       Here  you  can  match  comparison  operators  that you may use with the
1053       "lv_size" field which is of type "size" - it's =, !=, >=, >, <= and  <.
1054       You can find applicable comparison operators for other fields and other
1055       field types the same way.
1056
1057       To demonstrate selection functionality in LVM, we will create more  LVs
1058       in addition to lvol0 and lvol1 we used in our previous examples.
1059
1060       # lvs -o name,size,origin,snap_percent,tags,time
1061         LV    LSize Origin Snap%  LV Tags        CTime
1062         lvol4 4.00m lvol2  24.61                 2016-09-09 16:57:44 +0200
1063         lvol3 4.00m lvol2  5.08                  2016-09-09 16:56:48 +0200
1064         lvol2 8.00m               tagA,tagC,tagD 2016-09-09 16:55:12 +0200
1065         lvol1 4.00m                              2016-08-29 12:53:36 +0200
1066         lvol0 4.00m               tagA,tagB      2016-08-29 10:15:17 +0200
1067
1068       When  selecting  size  and  percent fields, we don't need to use units.
1069       For sizes, default "m" (for MiB) is used - this is the  same  behaviour
1070       as  already  used for LVM commands when specifying sizes (e.g. lvcreate
1071       -L).  For percent fields, "%" is  assumed  automatically  if  it's  not
1072       specified.   The  example  below also demonstrates how several criteria
1073       can be combined together.
1074
1075       # lvs -o name,size,snap_percent -S 'size=8m'
1076         LV    LSize
1077         lvol2 8.00m
1078
1079       # lvs -o name,size,snap_percent -S 'size=8'
1080         LV    LSize
1081         lvol2 8.00m
1082
1083       # lvs -o name,size,snap_percent -S 'size < 5000k'
1084         LV    LSize Snap%
1085         lvol4 4.00m 24.61
1086         lvol3 4.00m 5.08
1087         lvol1 4.00m
1088         lvol0 4.00m
1089
1090       # lvs -o name,size,snap_percent -S 'size < 5000k && snap_percent > 20'
1091         LV    LSize Snap%
1092         lvol4 4.00m 24.61
1093
1094       # lvs -o name,size,snap_percent \
1095           -S '(size < 5000k && snap_percent > 20%) || name=lvol2'
1096         LV    LSize Snap%
1097         lvol4 4.00m 24.61
1098         lvol2 8.00m
1099
1100       You can also use selection together with processing-oriented commands.
1101
1102       # lvchange --addtag test -S 'size < 5000k'
1103         Logical volume vg/lvol1 changed.
1104         Logical volume vg/lvol0 changed.
1105         Logical volume vg/lvol3 changed.
1106         Logical volume vg/lvol4 changed.
1107
1108       # lvchange --deltag test -S 'tags = test'
1109         Logical volume vg/lvol1 changed.
1110         Logical volume vg/lvol0 changed.
1111         Logical volume vg/lvol3 changed.
1112         Logical volume vg/lvol4 changed.
1113
1114       LVM can recognize more complex values used in  selection  criteria  for
1115       string list and time field types. For string lists, you can match whole
1116       list strictly, its subset or intersection. Let's take  "lv_tags"  field
1117       as  an  example  - we select only rows which contain "tagA" within tags
1118       field. We're using { } to denote that we're interested in  subset  that
1119       matches. If the subset has only one item, we can leave out { }.
1120
1121       # lvs -o name,tags -S 'tags={tagA}'
1122         LV    LV Tags
1123         lvol2 tagA,tagC,tagD
1124         lvol0 tagA,tagB
1125
1126       # lvs -o name,tags -S 'tags=tagA'
1127         LV    LV Tags
1128         lvol2 tagA,tagC,tagD
1129         lvol0 tagA,tagB
1130
1131       Depending  on  whether we use "&&" (or ",") or "||" ( or "#") as delim‐
1132       iter for items in the set we define in selection criterion  for  string
1133       list,  we  either match subset ("&&" or ",") or even intersection ("||"
1134       or "#").
1135
1136       # lvs -o name,tags -S 'tags={tagA,tagC,tagD}'
1137         LV    LV Tags
1138         lvol2 tagA,tagC,tagD
1139
1140       # lvs -o name,tags -S 'tags={tagA || tagC || tagD}'
1141         LV    LV Tags
1142         lvol2 tagA,tagC,tagD
1143         lvol0 tagA,tagB
1144
1145       To match the complete set, use [ ] with "&&" (or ",") as delimiter  for
1146       items.  Also note that the order in which we define items in the set is
1147       not relevant.
1148
1149       # lvs -o name,tags -S 'tags=[tagA]'
1150
1151       # lvs -o name,tags -S 'tags=[tagB,tagA]'
1152         LV    LV Tags
1153         lvol0 tagA,tagB
1154
1155       If you use [ ] with "||" (or "#"), this is exactly the same as using  {
1156       }.
1157
1158       # lvs -o name,tags -S 'tags=[tagA || tagC || tagD]'
1159         LV    LV Tags
1160         lvol2 tagA,tagC,tagD
1161         lvol0 tagA,tagB
1162
1163       To  match a set with no items, use "" to denote this (note that we have
1164       output compaction enabled so the "LV Tags" column is not  displayed  in
1165       the example below because it's blank and so it gets compacted).
1166
1167       # lvs -o name,tags -S 'tags=""'
1168         LV
1169         lvol4
1170         lvol3
1171         lvol1
1172
1173       # lvs -o name,tags -S 'tags!=""'
1174         LV    LV Tags
1175         lvol2 tagA,tagC,tagD
1176         lvol0 tagA,tagB
1177
1178       When  doing selection based on time fields, we can use either standard,
1179       absolute or freeform time expressions in selection  criteria.  Examples
1180       below are using standard forms.
1181
1182       # lvs -o name,time
1183         LV    CTime
1184         lvol4 2016-09-09 16:57:44 +0200
1185         lvol3 2016-09-09 16:56:48 +0200
1186         lvol2 2016-09-09 16:55:12 +0200
1187         lvol1 2016-08-29 12:53:36 +0200
1188         lvol0 2016-08-29 10:15:17 +0200
1189
1190       # lvs -o name,time -S 'time since "2016-09-01"'
1191         LV    CTime
1192         lvol4 2016-09-09 16:57:44 +0200
1193         lvol3 2016-09-09 16:56:48 +0200
1194         lvol2 2016-09-09 16:55:12 +0200
1195
1196       # lvs -o name,time -S 'time since "2016-09-09 16:56"'
1197         LV    CTime
1198         lvol4 2016-09-09 16:57:44 +0200
1199         lvol3 2016-09-09 16:56:48 +0200
1200
1201       # lvs -o name,time -S 'time since "2016-09-09 16:57:30"'
1202         LV    CTime
1203         lvol4 2016-09-09 16:57:44 +0200
1204
1205       # lvs -o name,time \
1206           -S 'time since "2016-08-29" && time until "2016-09-09 16:55:12"'
1207         LV    CTime
1208         lvol2 2016-09-09 16:55:12 +0200
1209         lvol1 2016-08-29 12:53:36 +0200
1210         lvol0 2016-08-29 10:15:17 +0200
1211
1212       # lvs -o name,time \
1213           -S 'time since "2016-08-29" && time before "2016-09-09 16:55:12"'
1214         LV    CTime
1215         lvol1 2016-08-29 12:53:36 +0200
1216         lvol0 2016-08-29 10:15:17 +0200
1217
1218       Time  operators  have synonyms: ">=" for since, "<=" for until, ">" for
1219       "after" and "<" for "before".
1220
1221       # lvs -o name,time \
1222           -S 'time >= "2016-08-29" && time <= "2016-09-09 16:55:30"'
1223         LV    CTime
1224         lvol2 2016-09-09 16:55:12 +0200
1225         lvol1 2016-08-29 12:53:36 +0200
1226         lvol0 2016-08-29 10:15:17 +0200
1227
1228       # lvs -o name,time \
1229           -S 'time since "2016-08-29" && time < "2016-09-09 16:55:12"'
1230         LV    CTime
1231         lvol1 2016-08-29 12:53:36 +0200
1232         lvol0 2016-08-29 10:15:17 +0200
1233
1234       Example below demonstrates using absolute time expression.
1235
1236       # lvs -o name,time --config report/time_format="%s"
1237         LV    CTime
1238         lvol4 1473433064
1239         lvol3 1473433008
1240         lvol2 1473432912
1241         lvol1 1472468016
1242         lvol0 1472458517
1243
1244       # lvs -o name,time -S 'time since @1473433008'
1245         LV    CTime
1246         lvol4 2016-09-09 16:57:44 +0200
1247         lvol3 2016-09-09 16:56:48 +0200
1248
1249       Examples below demonstrates using freeform time expressions.
1250
1251       # lvs -o name,time -S 'time since "2 weeks ago"'
1252         LV    CTime
1253         lvol4 2016-09-09 16:57:44 +0200
1254         lvol3 2016-09-09 16:56:48 +0200
1255         lvol2 2016-09-09 16:55:12 +0200
1256         lvol1 2016-08-29 12:53:36 +0200
1257         lvol0 2016-08-29 10:15:17 +0200
1258
1259       # lvs -o name,time -S 'time since "1 week ago"'
1260         LV    CTime
1261         lvol4 2016-09-09 16:57:44 +0200
1262         lvol3 2016-09-09 16:56:48 +0200
1263         lvol2 2016-09-09 16:55:12 +0200
1264
1265       # lvs -o name,time -S 'time since "2 weeks ago"'
1266         LV    CTime
1267         lvol1 2016-08-29 12:53:36 +0200
1268         lvol0 2016-08-29 10:15:17 +0200
1269
1270       # lvs -o name,time -S 'time before "1 week ago"'
1271         LV    CTime
1272         lvol1 2016-08-29 12:53:36 +0200
1273         lvol0 2016-08-29 10:15:17 +0200
1274
1275       # lvs -o name,time -S 'time since "68 hours ago"'
1276         LV    CTime
1277         lvol4 2016-09-09 16:57:44 +0200
1278         lvol3 2016-09-09 16:56:48 +0200
1279         lvol2 2016-09-09 16:55:12 +0200
1280
1281       # lvs -o name,time -S 'time since "1 year 3 months ago"'
1282         LV    CTime
1283         lvol4 2016-09-09 16:57:44 +0200
1284         lvol3 2016-09-09 16:56:48 +0200
1285         lvol2 2016-09-09 16:55:12 +0200
1286         lvol1 2016-08-29 12:53:36 +0200
1287         lvol0 2016-08-29 10:15:17 +0200
1288
1289   Command log reporting
1290       As described in categorization based on reporting facility  section  at
1291       the  beginning  of  this  document,  both  report-oriented and process‐
1292       ing-oriented LVM commands can report the command log if this is enabled
1293       with log/report_command_log configuration setting.  Just like any other
1294       report, we can set the set of fields to display  (log/command_log_cols)
1295       and to sort by (log/command_log_sort) for this report.
1296
1297       # lvmconfig --type full log/report_command_log log/command_log_cols \
1298          log/command_log_sort log/command_log_selection
1299       report_command_log=1
1300       command_log_cols="log_seq_num,log_type,log_context,log_object_type,
1301                         log_object_name,log_object_group,log_message,
1302                         log_errno,log_ret_code"
1303       command_log_sort="log_seq_num"
1304       command_log_selection="!(log_type=status && message=success)"
1305
1306       # lvs
1307         Logical Volume
1308         ==============
1309         LV    LSize Cpy%Sync
1310         lvol1 4.00m 100.00
1311         lvol0 4.00m
1312
1313         Command Log
1314         ===========
1315         Seq LogType Context ObjType ObjName ObjGrp  Msg     Errno RetCode
1316
1317       As  you  can  see,  the  command  log  is empty (it contains only field
1318       names).  By default, LVM uses selection on the command log  report  and
1319       this  case  no  row matched the selection criteria, see also log report
1320       specifics section in this document for more information. We're display‐
1321       ing complete log report in the example below where we can see that both
1322       LVs lvol0 and lvol1 were successfully processed as well as  the  VG  vg
1323       they are part of.
1324
1325       # lvmconfig --type full log/command_log_selection
1326       command_log_selection="all"
1327
1328       # lvs
1329         Logical Volume
1330         ==============
1331         LV    LSize Cpy%Sync
1332         lvol1 4.00m 100.00
1333         lvol0 4.00m
1334
1335         Command Log
1336         ===========
1337         Seq LogType Context    ObjType ObjName ObjGrp  Msg     Errno RetCode
1338           1 status  processing lv      lvol0   vg      success     0       1
1339           2 status  processing lv      lvol1   vg      success     0       1
1340           3 status  processing vg      vg              success     0       1
1341
1342       # lvchange -an vg/lvol1
1343         Command Log
1344         ===========
1345         Seq LogType Context    ObjType ObjName ObjGrp  Msg     Errno RetCode
1346           1 status  processing lv      lvol1   vg      success     0       1
1347           2 status  processing vg      vg              success     0       1
1348
1349   Handling multiple reports per single command
1350       To  configure  the  log report directly on command line, we need to use
1351       --configreport option before we start any  -o|--options,  -O|--sort  or
1352       -S|--select that is targeted for log report.
1353
1354       # lvs -o lv_name,lv_size --configreport log -o log_object_type, \
1355          log_object_name,log_message,log_ret_code
1356         Logical Volume
1357         ==============
1358         LV    LSize
1359         lvol1 4.00m
1360         lvol0 4.00m
1361
1362         Command Log
1363         ===========
1364         ObjType ObjName Msg     RetCode
1365         lv      lvol0   success       1
1366         lv      lvol1   success       1
1367         vg      vg      success       1
1368
1369       The lvm fullreport, with or without log report, consists of several re‐
1370       ports - the --configreport is also used to target particular  subreport
1371       here.
1372
1373       Below is an extended example with lvm fullreport to illustrate combina‐
1374       tion of various options. The report output is in JSON format.  Also, we
1375       configure  "vg",  "pvseg",  "seg"  and  "log" subreport to contain only
1376       specified fields. For the "pvseg" subreport, we're interested  only  in
1377       PV  names having "sda" in their name. For the "log" subreport we're in‐
1378       terested only in log lines related to either "lvol0" object  or  object
1379       having  "sda" in its name. Also, for the log subreport we define order‐
1380       ing to be based on "log_object_type" field.
1381
1382       # lvm fullreport --reportformat json \
1383          --configreport vg -o vg_name,vg_size \
1384          --configreport pvseg -o pv_name,pvseg_start \
1385                               -S 'pv_name=~sda' \
1386          --configreport seg -o lv_name,seg_start \
1387          --configreport log -o log_object_type,log_object_name \
1388                             -O log_object_type \
1389                             -S 'log_object_name=lvol0 || \
1390                                 log_object_name=~sda'
1391         {
1392             "report": [
1393                 {
1394                     "vg": [
1395                         {"vg_name":"vg", "vg_size":"200.00m"}
1396                     ]
1397                     ,
1398                     "pv": [
1399                         {"pv_name":"/dev/sda", "vg_name":"vg"},
1400                         {"pv_name":"/dev/sdb", "vg_name":"vg"}
1401                     ]
1402                     ,
1403                     "lv": [
1404                         {"lv_name":"lvol0", "vg_name":"vg"},
1405                         {"lv_name":"lvol1", "vg_name":"vg"}
1406                     ]
1407                     ,
1408                     "pvseg": [
1409                         {"pv_name":"/dev/sda", "pvseg_start":"0"},
1410                         {"pv_name":"/dev/sda", "pvseg_start":"1"},
1411                         {"pv_name":"/dev/sda", "pvseg_start":"2"},
1412                         {"pv_name":"/dev/sda", "pvseg_start":"3"}
1413                     ]
1414                     ,
1415                     "seg": [
1416                         {"lv_name":"lvol0", "seg_start":"0 "},
1417                         {"lv_name":"lvol1", "seg_start":"0 "}
1418                     ]
1419                 }
1420             ]
1421             ,
1422             "log": [
1423                 {"log_object_type":"lv", "log_object_name":"lvol0"},
1424                 {"log_object_type":"lv", "log_object_name":"lvol0"},
1425                 {"log_object_type":"pv", "log_object_name":"/dev/sda"},
1426                 {"log_object_type":"pv", "log_object_name":"/dev/sda"},
1427             ]
1428         }
1429
1430   Report extensions for LVM shell
1431       As already stated in log report coverage  paragraph  under  log  report
1432       specifics  in  this  documentation, when using LVM shell the log report
1433       coverage is wider. There's also special command designed to query  last
1434       command's log report in the LVM shell - the lastlog command.
1435
1436       The  example below illustrates a situation where we called lvs command.
1437       After that, we inspected the log report with the lastlog,  without  any
1438       selection  so all the log report is displayed on output. Then we called
1439       lastlog further, giving various selection criteria. Then we ran unknown
1440       LVM command "abc" for which the log report displays appropriate failure
1441       state.
1442
1443       # lvm
1444       lvm> lvs
1445         Logical Volume
1446         ==============
1447         LV    LSize Cpy%Sync
1448         lvol1 4.00m 100.00
1449         lvol0 4.00m
1450
1451         Command Log
1452         ===========
1453         Seq LogType Context    ObjType ObjName ObjGrp  Msg     Errno RetCode
1454           1 status  processing lv      lvol0   vg      success     0       1
1455           2 status  processing lv      lvol1   vg      success     0       1
1456           3 status  processing vg      vg              success     0       1
1457           4 status  shell      cmd     lvs             success     0       1
1458
1459       lvm> lastlog
1460         Command Log
1461         ===========
1462         Seq LogType Context    ObjType ObjName ObjGrp  Msg     Errno RetCode
1463           1 status  processing lv      lvol0   vg      success     0       1
1464           2 status  processing lv      lvol1   vg      success     0       1
1465           3 status  processing vg      vg              success     0       1
1466           4 status  shell      cmd     lvs             success     0       1
1467
1468       lvm> lastlog -S log_object_type=lv
1469         Command Log
1470         ===========
1471         Seq LogType Context    ObjType ObjName ObjGrp  Msg     Errno RetCode
1472           1 status  processing lv      lvol0   vg      success     0       1
1473           2 status  processing lv      lvol1   vg      success     0       1
1474
1475       lvm> lastlog -S log_context=shell
1476         Command Log
1477         ===========
1478         Seq LogType Context ObjType ObjName ObjGrp  Msg     Errno RetCode
1479           4 status  shell   cmd     lvs             success     0       1
1480
1481       lvm> abc
1482         Command Log
1483         ===========
1484         Seq LogType Context ObjType ObjName ObjGrp  Msg                                 Errno RetCode
1485           1 error   shell   cmd     abc             No such command 'abc'.  Try 'help'.    -1       0
1486           2 status  shell   cmd     abc             failure                                -1       2
1487

SEE ALSO

1489       lvm(8), lvmconfig(8), lvm fullreport(8), lvcreate(8),
1490       lvs(8), pvs(8), vgs(8),
1491
1492       date(1), strftime(3)
1493
1494
1495
1496Red Hat, Inc         LVM TOOLS 2.03.18(2)-git (2022-11-10)        LVMREPORT(7)
Impressum