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

NAME

6       lvmreport — LVM reporting and related features
7
8

DESCRIPTION

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

Categorization based on reporting facility

17       Based on functionality, commands which make use of the reporting infra‐
18       structure are divided in two groups:
19
20       Report-oriented
21              These  commands inform about current LVM state and their primary
22              role is to display this information in compendious way. To  make
23              a  distinction, we will name this report as main report. The set
24              of report-only  commands  include:  pvs,  vgs,  lvs,  pvdisplay,
25              vgdisplay, lvdisplay, lvm devtypes, lvm fullreport.  For further
26              information about main report, see main report specifics.
27
28       Processing-oriented
29              These commands are responsible for changing LVM state  and  they
30              do not contain any main report as identified for report-oriented
31              commands, they only perform some kind of processing. The set  of
32              processing-oriented   commands   includes:  pvcreate,  vgcreate,
33              lvcreate,  pvchange,  vgchange,  lvchange,  pvremove,  vgremove,
34              lvremove,  pvresize,  vgextend,  vgreduce,  lvextend,  lvreduce,
35              lvresize, lvrename, pvscan, vgscan, lvscan, pvmove, vgcfgbackup,
36              vgck, vgconvert, vgexport, vgimport, vgmknodes.
37
38       If  enabled,  so called log report is either displayed solely (for pro‐
39       cessing-oriented commands) or in addition to main report  (for  report-
40       oriented  commands).  The log report contains a log of operations, mes‐
41       sages and per-object status with complete  object  identification  col‐
42       lected  during LVM command execution. See log report specifics for more
43       information about this report type.
44
45
46

Terms

48       When describing reporting functionality and features in this  text,  we
49       will use terms row and column. By row we mean series of values reported
50       for single entity (for example single PV, VG or LV).  Each  value  from
51       the row then belongs to a column of certain type. The columns have col‐
52       umn headings which are short descriptions for the columns. The  columns
53       are  referenced  by  column  names.  Please note that this text is also
54       using term field interchangeably with the term column. Most of the time
55       the term columns is abbreviated as col in configuration.
56
57

Common report configuration settings and command line options

59       There  are common configuration settings and command line options which
60       apply to both main report and log report. Following lists  contain  all
61       of them, separated into groups based on their use.
62
63              Common configuration settings:
64
65
66
67                     ·  Changing  report  output format, composition and other
68                        output modifiers:
69
70                        -  global/units
71
72                        -  global/suffix
73
74                        -  report/output_format
75
76                        -  report/compact_output
77
78                        -  report/compact_output_cols
79
80                        -  report/aligned
81
82                        -  report/headings
83
84                        -  report/separator
85
86                        -  report/list_item_separator
87
88                        -  report/prefixes
89
90                        -  report/quoted
91
92                        -  report/columns_as_rows
93
94                        -  report/binary_values_as_numeric
95
96                        -  report/time_format
97
98                        -  report/mark_hidden_devices
99
100                        -  report/two_word_unknown_device
101
102
103                     ·  Special settings
104
105                        -  report/buffered
106
107
108
109       This document does not describe these settings in more detail - if  you
110       need  detailed information, including values which are accepted for the
111       settings, please run lvmconfig --type default --withcomments <setting>.
112       There  are  more  configuration  settings in addition to the common set
113       listed above, but they are  specific  to  either  main  report  or  log
114       report,  see  main  report specifics and log report specifics for these
115       settings. Besides configuring reports globally by  using  configuration
116       settings,  there  are  also command line options you can use to extend,
117       override or further specify the report configuration.
118
119              Common command line options:
120
121
122
123                     ·  Definition of the set set of fields to use
124
125                        -  --options|-o FieldSet
126                           Field set to use. See main report specifics and log
127                           report  specifics  for information about field sets
128                           configured with global configuratin  settings  that
129                           this option overrides.
130
131                        -  --options|-o+ FieldSet
132                           Fields  to  include  to current field set. See main
133                           report  specifics and  log  report  specifics   for
134                           information about field sets configured with global
135                           configuration settings that this option extends.
136
137                        -  --options|-o- FieldSet
138                           Fields to exclude from current field set. See  main
139                           report  specifics  and  log  report  specifics  for
140                           information about field sets configured with global
141                           configuration settings that this option reduces.
142
143                        -  --options|-o# FieldSet
144                           Compaction  of unused fields. Overrides report/com‐
145                           pact_output_cols configuration setting.
146
147
148                     ·  Sorting
149
150                        -  --sort|-O+ FieldSet
151                           Fields to sort by  in  ascending  order.  See  main
152                           report  specifics  and  log  report  specifics  for
153                           information about field sets configured with global
154                           configuration settings that this option overrides.
155
156                        -  --sort|-O- FieldSet
157                           Fields  to  sort  by  in descending order. See main
158                           report  specifics  and  log  report  specifics  for
159                           information   about  fields  sets  configured  with
160                           global configuration  settings  that  this  options
161                           overrides.
162
163
164                     ·  Selection
165
166                        -  --select|-S Selection
167                           Define  selection  criteria  for report output. For
168                           log   report,   this   also   overrides    log/com‐
169                           mand_log_selection  configuration setting, see also
170                           log report specifics.
171
172
173                     ·  Changing output format and composition
174
175                        -  --reportformat
176                           Overrides report/output_format  configuration  set‐
177                           ting.
178
179                        -  --aligned
180                           Overrides report/aligned configuration setting.
181
182                        -  --binary
183                           Overrides  report/binary_values_as_numeric configu‐
184                           ration setting.
185
186                        -  --nameprefixes
187                           Overrides report/prefixes configuration setting.
188
189                        -  --noheadings
190                           Overrides report/noheadings configuration setting.
191
192                        -  --nosuffix
193                           Overrides global/suffix configuration setting.
194
195                        -  --rows
196                           Overrides report/columns_as_rows configuration set‐
197                           ting.
198
199                        -  --separator
200                           Overrides report/separator configuration setting.
201
202                        -  --units
203                           Overrides global/units configuration setting.
204
205                        -  --unquoted
206                           Overrides report/quoted configuration setting.
207
208
209                     ·  Special options
210
211                        -  --configreport ReportName
212                           This  defines  the  ReportName for which any subse‐
213                           quent -o--columns, -O--sort or  -S--select  applies
214                           to.  See  also main report specifics and log report
215                           specifics for possible ReportName values.
216
217                        -  --logonly
218                           When an LVM command contains both main  report  and
219                           log  report, this option suppresses the main report
220                           output and it causes the log report  output  to  be
221                           displayed only.
222
223                        -  --unbuffered
224                           Overrides report/bufffered configuration setting.
225
226
227
228       The FieldSet mentioned in the lists above is a set of field names where
229       each field name is delimited by "," character.  Field  set  definition,
230       sorting  and  selection  may  be  repeated  on  command  line  (-o+/-o-
231       includes/excludes fields  to/from  current  list,  for  all  the  other
232       repeatable  options, the last value typed for the option on the command
233       line is used). The Selection is a string with selection  criteria,  see
234       also  Selection paragraph below for more information about constructing
235       these criteria.
236
237
238

Main report specifics

240       The main report currently encompasses these distinct  subtypes,  refer‐
241       enced by their name - ReportName as listed below. The command in paren‐
242       thesis is representative command that uses the main report  subtype  by
243       default.   Each  subtype  has  its own configuration setting for global
244       field set definition as well as sort  field  definition  (listed  below
245       each individual ReportName):
246
247
248
249              ·  pv representing report about Physical Volumes (pvs)
250
251                 -  report/pvs_cols
252
253                 -  report/pvs_sort
254
255
256              ·  pvseg representing report about Physical Volume Segments (pvs
257                 --segments)
258
259                 -  report/pvseg_cols
260
261                 -  report/pvseg_sort
262
263
264              ·  vg representing report about Volume Groups (vgs)
265
266                 -  report/vgs_cols
267
268                 -  report/vgs_sort
269
270
271              ·  lv representing report about Logical Volumes (lvs)
272
273                 -  report/lvs_cols
274
275                 -  report/lvs_sort
276
277
278              ·  seg representing report about Logical  Volume  Segments  (lvs
279                 --segments)
280
281                 -  report/segs_cols
282
283                 -  report/segs_sort
284
285
286              ·  full  representing  report  combining  all  of the above as a
287                 whole (lvm fullreport)
288
289                 -  report/pvs_cols_full
290
291                 -  report/pvs_sort_full
292
293                 -  report/pvsegs_cols_full
294
295                 -  report/pvseg_sort_full
296
297                 -  report/vgs_cols_full
298
299                 -  report/vgs_sort_full
300
301                 -  report/lvs_cols_full
302
303                 -  report/lvs_sort_full
304
305                 -  report/segs_cols_full
306
307                 -  report/segs_sort_full
308
309
310              ·  devtype representing report about device types (lvm devtypes)
311
312                 -  report/devtypes_cols
313
314                 -  report/devtypes_sort
315
316
317       Use pvs, vgs, lvs -o help or lvm devtypes -o help to get complete  list
318       of  fields  that you can use for main report. The list of fields in the
319       help output is separated in groups based  on  which  report  type  they
320       belong  to.   Note that LVM can change final report type used if fields
321       from different groups are combined together. Some of these combinations
322       are not allowed in which case LVM will issue an error.
323
324       For  all  main  report  subtypes except full, it's not necessary to use
325       --configreport ReportName to denote which report any subsequent -o,  -O
326       or  -S option applies to as they always apply to the single main report
327       type. Currently, lvm fullreport is the only command that includes  more
328       than one main report subtype. Therefore, the --configreport is particu‐
329       larly suitable for the full report if you need to configure each of its
330       subreports in a different way.
331
332
333

Log report specifics

335       You  can  enable  log  report with log/report_command_log configuration
336       setting - this functionality is disabled by  default.  The  log  report
337       contains  a log collected during LVM command execution and then the log
338       is displayed just like any other report known from main  report.  There
339       is  only  one  log  report subtype as shown below together with related
340       configuration settings for fields, sorting and selection:
341
342
343
344              ·  log representing log report
345
346                 -  log/command_log_cols
347
348                 -  log/command_log_sort
349
350                 -  log/command_log_selection
351
352
353       You always need to use --configreport log  together  with  -o--options,
354       -O--sort  or  -S--selection to override configuration settings directly
355       on command line for log report. When compared to main report, in  addi‐
356       tion to usual configuration settings for report fields and sorting, the
357       log report has also configuration option for  selection  -  report/com‐
358       mand_log_selection.  This  configuration setting is provided for conve‐
359       nience so it's not necessary to use -S--select  on  command  line  each
360       time an LVM command is executed and we need the same selection criteria
361       to be applied for log report. Default selection criteria used  for  log
362       report are log/command_log_selection="!(log_type=status && message=suc‐
363       cess)".  This means that, by default, log report doesn't display status
364       messages  about  successful  operation  and  it displays only rows with
365       error, warning, print-type messages and messages about  failure  states
366       (for more information, see log report content below).
367
368       Log report coverage
369       Currently,  when  running LVM commands directly (not in LVM shell), the
370       log report covers command's processing stage which is the  moment  when
371       LVM  entities  are iterated and processed one by one. It does not cover
372       any command initialization nor command finalization stage. If there  is
373       any  message  issued  out  of log report's coverage range, such message
374       goes directly to output, bypassing the log report. By default, that  is
375       standard  error output for error and warning messages and standard out‐
376       put for common print-like messages.
377
378       When running LVM commands in LVM shell, the log report covers the whole
379       LVM command's execution, including command's processing as well as ini‐
380       tialization and finalization stage. So from this point of view, the log
381       report  coverage is complete for executed LVM commands. Note that there
382       are still a few moments when  LVM  shell  needs  to  initialize  itself
383       before  it even enters the main loop in which it executes LVM commands.
384       Also, there is a moment when LVM shell  needs  to  prepare  log  report
385       properly  for  next  command  executed in the shell and then, after the
386       command's run, the shell needs to  display  the  log  report  for  that
387       recently  executed  command. If there is a failure or any other message
388       issued during this time, the LVM will bypass  log  report  and  display
389       messages on output directly.
390
391       For these reasons and for completeness, it's not possible to rely fully
392       on log report as the only indicator of LVM  command's  status  and  the
393       only  place  where all messages issued during LVM command execution are
394       collected.  You always need to check whether the command has not failed
395       out of log report's range by checking the non-report output too.
396
397       To  help with this, LVM can separate output which you can then redirect
398       to any custom file descriptor that you prepare before  running  an  LVM
399       command  or  LVM shell and then you make LVM to use these file descrip‐
400       tors for different kinds of output by  defining  environment  variables
401       with  file  descriptor  numbers.  See  also  LVM_OUT_FD, LVM_ERR_FD and
402       LVM_REPORT_FD environment variable description in lvm(8) man page.
403
404       Also note that, by default, reports use the  same  file  descriptor  as
405       common  print-like  messages,  which is standard output. If you plan to
406       use log report in your scripts or any external  tool,  you  should  use
407       LVM_OUT_FD,  LVM_ERR_FD  and LVM_REPORT_FD to separate all output types
408       to different file descriptors. For example, with bash, that would be:
409
410              LVM_OUT_FD=3   LVM_ERR_FD=4   LVM_REPORT_FD=5   <lvm    command>
411              3>out_file 4>err_file 5>report_file
412
413       Where the <lvm_command> is either direct LVM command or LVM shell.  You
414       can collect all three types of output in particular files then.
415
416       Log report content
417       Each item in the log report consists of these set of  fields  providing
418       various information:
419
420
421
422              ·  Basic information (mandatory):
423
424                 -  log_seq_num
425                    Item  sequence  number.  The sequence number is unique for
426                    each log item and it increases in the  order  of  the  log
427                    items as they appeared during LVM command execution.
428
429
430                 -  log_type
431                    Type of log for the item. Currently, these types are used:
432
433                           status for any status information that is logged
434
435                           print  for any common message printed while the log
436                           is collected
437
438                           error for any error message printed while  the  log
439                           is collected
440
441                           warn  for any warning message printed while the log
442                           is collected
443
444
445                 -  log_context
446                    Context of the log for the item. Currently,  two  contexts
447                    are identified:
448
449                           shell  for  the log collected in the outermost code
450                           before and after executing concrete LVM commands
451
452                           processing for the log collected  while  processing
453                           LVM entities during LVM command execution
454
455
456
457              ·  Message (mandatory):
458
459                 -  log_message
460                    Any  message  associated with current item. For status log
461                    type, the  message  contains  either  success  or  failure
462                    denoting  current  state.  For  print,  error and warn log
463                    types, the message contains the exact message of that type
464                    that got issued.
465
466
467              ·  Object information (used only if applicable):
468
469                 -  log_object_type field
470                    Type  of  the  object  processed.  Currently, these object
471                    types are recognized:
472
473                           cmd for command as a whole
474
475                           orphan for processing group of PVs not  in  any  VG
476                           yet
477
478                           pv for PV processing
479
480                           label  for  direct  PV label processing (without VG
481                           metadata)
482
483                           vg for VG processing
484
485                           lv for LV processing
486
487
488                 -  log_object_name
489                    Name of the object processed.
490
491
492                 -  log_object_id
493                    ID of the object processed.
494
495
496                 -  log_object_group
497                    A group where the processed object belongs to.
498
499
500                 -  log_object_group_id
501                    An ID of a group where the processed object belongs to.
502
503
504              ·  Numeric status (used only if applicable)
505
506                 -  log_errno
507                    Error number associated with current item.
508
509                 -  log_ret_code
510                    Rreturn code associated with current item.
511
512
513
514       You can also run <lvm_command> --configreport log -o help to to display
515       complete list of fields that you may use for the log report.
516
517

Selection

519       Selection  is  used for a report to display only rows that match selec‐
520       tion criteria. All rows are  displayed  with  the  additional  selected
521       field (-o selected) displaying 1 if the row matches the Selection and 0
522       otherwise. The selection criteria are a set of statements  combined  by
523       logical and grouping operators.  The statement consists of a field name
524       for which a set of valid values is defined using comparison  operators.
525       For  complete  list  of fields names that you can use in selection, see
526       the output of <lvm_command> -S help. The help output also contains type
527       of values that each field displays enclosed in brackets.
528
529       List of operators recognized in selection criteria
530
531              ·  Comparison operators (cmp_op)
532
533                        =~ matching regular expression.
534
535                        !~ not matching regular expression.
536
537                        =  equal to.
538
539                        != not equal to.
540
541                        >= greater than or equal to.
542
543                        >  greater than
544
545                        <= less than or equal to.
546
547                        <  less than.
548
549
550              ·  Binary logical operators (cmp_log)
551
552                        && all fields must match
553
554                        ,  all fields must match
555
556                        || at least one field must match
557
558                        #  at least one field must match
559
560
561              ·  Unary logical operators
562
563                        !  logical negation
564
565
566              ·  Grouping operators
567
568                        (  left parenthesis
569
570                        )  right parenthesis
571
572                        [  list start
573
574                        ]  list end
575
576                        {  list subset start
577
578                        }  list subset end
579
580
581       Field types and selection operands
582       Field  type  restricts the set of operators and values that you may use
583       with the field when defining selection criteria. You can see field type
584       for  each field if you run <lvm command> -S help where you can find the
585       type name enclosed in square brackets. Currently, LVM recognizes  these
586       field types in reports:
587
588
589              ·  string for set of characters (for each string field type, you
590                 can use either string or regular expression - regex  for  the
591                 value used in selection criteria)
592
593              ·  string list for set of strings
594
595              ·  number for integer value
596
597              ·  size for integer or floating point number with size unit suf‐
598                 fix (see  also  lvcreate(8)  man  page  and  description  for
599                 "-L--size" option for the list of recognized suffixes)
600
601              ·  percent  for floating point number with or without "%" suffix
602                 (e.g. 50 or 50%)
603
604              ·  time for time values
605
606       When using string list in selection criteria, there  are  several  ways
607       how  LVM  can  match  string list fields from report, depending on what
608       list grouping operator is used and what item separator is  used  within
609       that set of items. Also, note that order of items does not matter here.
610
611
612              ·  matching  the set strictly where all items must match - use [
613                 ], e.g.  ["a","b","c"]
614
615              ·  matching a subset of the set - use { } with ","  or  "&&"  as
616                 item delimiter, e.g. {"a","b","c"}
617
618              ·  matching  an  intersection with the set - use { } with "#" or
619                 "||" as item delimiter, e.g. {"a" || "b" || "c"}
620
621       When using time in your selection criteria, LVM can  recognize  various
622       time  formats  using  standard,  absolute  or freeform expressions. For
623       examples demonstrating time  expressions  in  selection  criteria,  see
624       EXAMPLES section.
625
626
627
628              ·  Standard time format
629
630
631                 -  date
632
633                           YYYY-MM-DD
634
635                           YYYY-MM, auto DD=1
636
637                           YYYY, auto MM=01 and DD=01
638
639
640                 -  time
641
642                           hh:mm:ss
643
644                           hh:mm, auto ss=0
645
646                           hh, auto mm=0, auto ss=0
647
648
649                 -  timezone
650
651                           +hh:mm or -hh:mm
652
653                           +hh or -hh
654
655                 The  full  date/time  specification  is  YYYY-MM-DD hh:mm:ss.
656                 Users are able to leave date/time parts from right  to  left.
657                 Whenever  these  parts are left out, a range is assumed auto‐
658                 matically with second granularity. For example:
659
660
661                           "2015-07-07  9:51"  means  range   of   "2015-07-07
662                           9:51:00" - "2015-07-07 9:51:59".
663
664                           "2015-07"  means  range  of  "2015-07-01 0:00:00" -
665                           "2015-07-31 23:59:59"
666
667                           "2015"  means  range  of  "2015-01-01  0:00:00"   -
668                           "2015-12-31 23:59:59"
669
670
671
672              ·  Absolute time format
673
674                 Absolute time is defined as number of seconds since the Epoch
675                 (1970:01:01 00:00 +00:00).
676
677
678                 -  @seconds
679
680
681              ·  Freeform time format
682
683                 -  weekday names ("Sunday" -  "Saturday"  or  abbreviated  as
684                    "Sun" - "Sat")
685
686                 -  labels for points in time ("noon", "midnight")
687
688                 -  labels  for  a day relative to current day ("today", "yes‐
689                    terday")
690
691                 -  points back in time with relative offset from today (N  is
692                    a number)
693
694                           "N"  "seconds"  /  "minutes"  /  "hours" / "days" /
695                           "weeks" / "years" "ago"
696
697                           "N" "secs" / "mins" / "hrs" ... "ago"
698
699                           "N" "s" / "m" / "h" ... "ago"
700
701                 -  time specification either in hh:mm:ss format or with AM/PM
702                    suffixes
703
704                 -  month  names  ("January"  -  "December"  or abbreviated as
705                    "Jan" - "Dec")
706
707
708       Informal grammar specification
709
710                     STATEMENT = column cmp_op VALUE | STATEMENT log_op STATE‐
711                     MENT | (STATEMENT) | !(STATEMENT)
712
713                     VALUE = [VALUE log_op VALUE]
714                     For list-based types: string list. Matches strictly.  The
715                     log_op must always be of one type within the  whole  list
716                     value.
717
718                     VALUE = {VALUE log_op VALUE}
719                     For list-based types: string list. Matches a subset.  The
720                     log_op must always be of one type within the  whole  list
721                     value.
722
723                     VALUE = value
724                     For  scalar  types:  number,  size,  percent,  string (or
725                     string regex).
726
727

EXAMPLES

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

SEE ALSO

1638       lvm (8), lvmconfig (8), lvm fullreport (8)
1639
1640
1641
1642Red Hat, Inc           LVM TOOLS 2.03.10(2) (2020-08-09)          LVMREPORT(7)
Impressum