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 us‐
54       ing 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  re‐
114       port, see main report specifics and log report specifics for these set‐
115       tings. Besides configuring reports globally by using configuration set‐
116       tings, there are also command line options you can use to extend, over‐
117       ride 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  in‐
134                           formation  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 in‐
140                           formation 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  re‐
152                           port  specifics and log report specifics for infor‐
153                           mation about field sets configured with global con‐
154                           figuration settings that this option overrides.
155
156                        -  --sort|-O- FieldSet
157                           Fields to sort by in descending order. See main re‐
158                           port specifics and log report specifics for  infor‐
159                           mation  about  fields  sets  configured with global
160                           configuration settings that this options overrides.
161
162
163                     •  Selection
164
165                        -  --select|-S Selection
166                           Define selection criteria for  report  output.  For
167                           log report, this also overrides log/command_log_se‐
168                           lection configuration setting, see also log  report
169                           specifics.
170
171
172                     •  Changing output format and composition
173
174                        -  --reportformat
175                           Overrides  report/output_format  configuration set‐
176                           ting.
177
178                        -  --aligned
179                           Overrides report/aligned configuration setting.
180
181                        -  --binary
182                           Overrides report/binary_values_as_numeric  configu‐
183                           ration setting.
184
185                        -  --nameprefixes
186                           Overrides report/prefixes configuration setting.
187
188                        -  --noheadings
189                           Overrides report/noheadings configuration setting.
190
191                        -  --nosuffix
192                           Overrides global/suffix configuration setting.
193
194                        -  --rows
195                           Overrides report/columns_as_rows configuration set‐
196                           ting.
197
198                        -  --separator
199                           Overrides report/separator configuration setting.
200
201                        -  --units
202                           Overrides global/units configuration setting.
203
204                        -  --unquoted
205                           Overrides report/quoted configuration setting.
206
207
208                     •  Special options
209
210                        -  --configreport ReportName
211                           This defines the ReportName for  which  any  subse‐
212                           quent  -o--columns,  -O--sort or -S--select applies
213                           to. See also main report specifics and  log  report
214                           specifics for possible ReportName values.
215
216                        -  --logonly
217                           When  an  LVM command contains both main report and
218                           log report, this option suppresses the main  report
219                           output  and  it  causes the log report output to be
220                           displayed only.
221
222                        -  --unbuffered
223                           Overrides report/bufffered configuration setting.
224
225
226
227       The FieldSet mentioned in the lists above is a set of field names where
228       each  field  name  is delimited by "," character. Field set definition,
229       sorting and selection may be repeated  on  command  line  (-o+/-o-  in‐
230       cludes/excludes  fields to/from current list, for all the other repeat‐
231       able options, the last value typed for the option on the  command  line
232       is  used).  The Selection is a string with selection criteria, see also
233       Selection paragraph below for more information about constructing these
234       criteria.
235
236
237

Main report specifics

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

Log report specifics

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

Selection

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

EXAMPLES

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

SEE ALSO

1636       lvm (8), lvmconfig (8), lvm fullreport (8)
1637
1638
1639
1640Red Hat, Inc           LVM TOOLS 2.03.11(2) (2021-01-08)          LVMREPORT(7)
Impressum