1LVMREPORT(7) LVMREPORT(7)
2
3
4
6 lvmreport — LVM reporting and related features
7
8
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
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
38If enabled, so called log report is either displayed solely (for processing-
39oriented commands) or in addition to main report (for report-oriented com‐
40mands). The log report contains a log of operations, messages and per-object
41status with complete object identification collected during LVM command execu‐
42tion. See log report specifics for more information about this report type.
43
44
45
47 When describing reporting functionality and features in this text, we
48 will use terms row and column. By row we mean series of values reported
49 for single entity (for example single PV, VG or LV). Each value from
50 the row then belongs to a column of certain type. The columns have col‐
51 umn headings which are short descriptions for the columns. The columns
52 are referenced by column names. Please note that this text is also
53 using term field interchangeably with the term column. Most of the time
54 the term columns is abbreviated as col in configuration.
55
56
58 There are common configuration settings and command line options which
59 apply to both main report and log report. Following lists contain all
60 of them, separated into groups based on their use.
61
62 Common configuration settings:
63
64
65
66 · Changing report output format, composition and other
67 output modifiers:
68
69 - global/units
70
71 - global/suffix
72
73 - report/output_format
74
75 - report/compact_output
76
77 - report/compact_output_cols
78
79 - report/aligned
80
81 - report/headings
82
83 - report/separator
84
85 - report/list_item_separator
86
87 - report/prefixes
88
89 - report/quoted
90
91 - report/columns_as_rows
92
93 - report/binary_values_as_numeric
94
95 - report/time_format
96
97 - report/mark_hidden_devices
98
99 - report/two_word_unknown_device
100
101
102 · Special settings
103
104 - report/buffered
105
106
107
108 This document does not describe these settings in more detail - if you
109 need detailed information, including values which are accepted for the
110 settings, please run lvmconfig --type default --withcomments <setting>.
111 There are more configuration settings in addition to the common set
112 listed above, but they are specific to either main report or log
113 report, see main report specifics and log report specifics for these
114 settings. Besides configuring reports globally by using configuration
115 settings, there are also command line options you can use to extend,
116 override or further specify the report configuration.
117
118 Common command line options:
119
120
121
122 · Definition of the set set of fields to use
123
124 - --options|-o FieldSet
125 Field set to use. See main report specifics and log
126 report specifics for information about field sets
127 configured with global configuratin settings that
128 this option overrides.
129
130 - --options|-o+ FieldSet
131 Fields to include to current field set. See main
132 report specifics and log report specifics for
133 information about field sets configured with global
134 configuration settings that this option extends.
135
136 - --options|-o- FieldSet
137 Fields to exclude from current field set. See main
138 report specifics and log report specifics for
139 information about field sets configured with global
140 configuration settings that this option reduces.
141
142 - --options|-o# FieldSet
143 Compaction of unused fields. Overrides report/com‐
144 pact_output_cols configuration setting.
145
146
147 · Sorting
148
149 - --sort|-O+ FieldSet
150 Fields to sort by in ascending order. See main
151 report specifics and log report specifics for
152 information about field sets configured with global
153 configuration settings that this option overrides.
154
155 - --sort|-O- FieldSet
156 Fields to sort by in descending order. See main
157 report specifics and log report specifics for
158 information about fields sets configured with
159 global configuration settings that this options
160 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/com‐
168 mand_log_selection configuration setting, see also
169 log report 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-
230 includes/excludes fields to/from current list, for all the other
231 repeatable options, the last value typed for the option on the command
232 line is used). The Selection is a string with selection criteria, see
233 also Selection paragraph below for more information about constructing
234 these criteria.
235
236
237
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
248 · pv representing report about Physical Volumes (pvs)
249
250 - report/pvs_cols
251
252 - report/pvs_sort
253
254
255 · pvseg representing report about Physical Volume Segments (pvs
256 --segments)
257
258 - report/pvseg_cols
259
260 - report/pvseg_sort
261
262
263 · vg representing report about Volume Groups (vgs)
264
265 - report/vgs_cols
266
267 - report/vgs_sort
268
269
270 · lv representing report about Logical Volumes (lvs)
271
272 - report/lvs_cols
273
274 - report/lvs_sort
275
276
277 · seg representing report about Logical Volume Segments (lvs
278 --segments)
279
280 - report/segs_cols
281
282 - report/segs_sort
283
284
285 · full 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
309 · devtype 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
319 belong 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
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
343 · log 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
364 error, 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
382 before 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
386 recently executed command. If there is a failure or any other message
387 issued during this time, the LVM will bypass log report and display
388 messages 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
461 denoting current state. For print, error and warn log
462 types, the message contains the exact message of that type
463 that 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
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
588 · string 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
592 · string list for set of strings
593
594 · number for integer value
595
596 · size 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
600 · percent for floating point number with or without "%" suffix
601 (e.g. 50 or 50%)
602
603 · time 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
611 · matching the set strictly where all items must match - use [
612 ], e.g. ["a","b","c"]
613
614 · matching a subset of the set - use { } with "," or "&&" as
615 item delimiter, e.g. {"a","b","c"}
616
617 · matching 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
622 examples demonstrating time expressions in selection criteria, see
623 EXAMPLES section.
624
625
626
627 · Standard 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
671 · Absolute 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
680 · Freeform 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
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
924 -o--options # 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
1122 report/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
1137 examples 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),
1154 report/noheadings (--noheadings), report/columns_as_rows (--rows) or
1155 report/buffered (--unbuffered). All these configuration settings and
1156 command line options are ignored if using the JSON report output for‐
1157 mat.
1158
1159
1160 Selection
1161 If you need to select only specific rows from report, you can use LVM's
1162 report selection feature. If you call <lvm_command> -S help, you'll get
1163 quick help on selection. The help contains list of all fields that LVM
1164 can use in reports together with its type enclosed in square brackets.
1165 The example below contains a line from lvs -S help.
1166
1167 # lvs -S help
1168 ...
1169 lv_size - Size of LV in current units. [size]
1170 ...
1171
1172 This line tells you you that the "lv_size" field is of "size" type. If
1173 you look at the bottom of the help output, you can see section about
1174 "Selection operators" and its "Comparison operators".
1175
1176 # lvs -S help
1177 ...
1178 Selection operators
1179 -------------------
1180 Comparison operators:
1181 =~ - Matching regular expression. [regex]
1182 !~ - Not matching regular expression. [regex]
1183 = - Equal to. [number, size, percent, string, string list, time]
1184 != - Not equal to. [number, size, percent, string, string_list, time]
1185 >= - Greater than or equal to. [number, size, percent, time]
1186 > - Greater than. [number, size, percent, time]
1187 <= - Less than or equal to. [number, size, percent, time]
1188 < - Less than. [number, size, percent, time]
1189 since - Since specified time (same as '>='). [time]
1190 after - After specified time (same as '>'). [time]
1191 until - Until specified time (same as '<='). [time]
1192 before - Before specified time (same as '<'). [time]
1193 ...
1194
1195 Here you can match comparison operators that you may use with the
1196 "lv_size" field which is of type "size" - it's =, !=, >=, >, <= and <.
1197 You can find applicable comparison operators for other fields and other
1198 field types the same way.
1199
1200 To demostrate selection functionality in LVM, we will create more LVs
1201 in addition to lvol0 and lvol1 we used in our previous examples.
1202
1203 # lvs -o name,size,origin,snap_percent,tags,time
1204 LV LSize Origin Snap% LV Tags CTime
1205 lvol4 4.00m lvol2 24.61 2016-09-09 16:57:44 +0200
1206 lvol3 4.00m lvol2 5.08 2016-09-09 16:56:48 +0200
1207 lvol2 8.00m tagA,tagC,tagD 2016-09-09 16:55:12 +0200
1208 lvol1 4.00m 2016-08-29 12:53:36 +0200
1209 lvol0 4.00m tagA,tagB 2016-08-29 10:15:17 +0200
1210
1211 When selecting size and percent fields, we don't need to use units.
1212 For sizes, default "m" (for MiB) is used - this is the same behaviour
1213 as already used for LVM commands when specifying sizes (e.g. lvcreate
1214 -L). For percent fields, "%" is assumed automatically if it's not
1215 specified. The example below also demonstrates how several criteria
1216 can be combined together.
1217
1218 # lvs -o name,size,snap_percent -S 'size=8m'
1219 LV LSize
1220 lvol2 8.00m
1221
1222 # lvs -o name,size,snap_percent -S 'size=8'
1223 LV LSize
1224 lvol2 8.00m
1225
1226 # lvs -o name,size,snap_percent -S 'size < 5000k'
1227 LV LSize Snap%
1228 lvol4 4.00m 24.61
1229 lvol3 4.00m 5.08
1230 lvol1 4.00m
1231 lvol0 4.00m
1232
1233 # lvs -o name,size,snap_percent -S 'size < 5000k && snap_percent > 20'
1234 LV LSize Snap%
1235 lvol4 4.00m 24.61
1236
1237 # lvs -o name,size,snap_percent \
1238 -S '(size < 5000k && snap_percent > 20%) || name=lvol2'
1239 LV LSize Snap%
1240 lvol4 4.00m 24.61
1241 lvol2 8.00m
1242
1243 You can also use selection together with processing-oriented commands.
1244
1245 # lvchange --addtag test -S 'size < 5000k'
1246 Logical volume vg/lvol1 changed.
1247 Logical volume vg/lvol0 changed.
1248 Logical volume vg/lvol3 changed.
1249 Logical volume vg/lvol4 changed.
1250
1251 # lvchange --deltag test -S 'tags = test'
1252 Logical volume vg/lvol1 changed.
1253 Logical volume vg/lvol0 changed.
1254 Logical volume vg/lvol3 changed.
1255 Logical volume vg/lvol4 changed.
1256
1257 LVM can recognize more complex values used in selection criteria for
1258 string list and time field types. For string lists, you can match whole
1259 list strictly, its subset or intersection. Let's take "lv_tags" field
1260 as an example - we select only rows which contain "tagA" within tags
1261 field. We're using { } to denote that we're interested in subset that
1262 matches. If the subset has only one item, we can leave out { }.
1263
1264 # lvs -o name,tags -S 'tags={tagA}'
1265 LV LV Tags
1266 lvol2 tagA,tagC,tagD
1267 lvol0 tagA,tagB
1268
1269 # lvs -o name,tags -S 'tags=tagA'
1270 LV LV Tags
1271 lvol2 tagA,tagC,tagD
1272 lvol0 tagA,tagB
1273
1274 Depending on whether we use "&&" (or ",") or "||" ( or "#") as delim‐
1275 iter for items in the set we define in selection criterion for string
1276 list, we either match subset ("&&" or ",") or even intersection ("||"
1277 or "#").
1278
1279 # lvs -o name,tags -S 'tags={tagA,tagC,tagD}'
1280 LV LV Tags
1281 lvol2 tagA,tagC,tagD
1282
1283 # lvs -o name,tags -S 'tags={tagA || tagC || tagD}'
1284 LV LV Tags
1285 lvol2 tagA,tagC,tagD
1286 lvol0 tagA,tagB
1287
1288 To match the complete set, use [ ] with "&&" (or ",") as delimiter for
1289 items. Also note that the order in which we define items in the set is
1290 not relevant.
1291
1292 # lvs -o name,tags -S 'tags=[tagA]'
1293
1294 # lvs -o name,tags -S 'tags=[tagB,tagA]'
1295 LV LV Tags
1296 lvol0 tagA,tagB
1297
1298 If you use [ ] with "||" (or "#"), this is exactly the same as using {
1299 }.
1300
1301 # lvs -o name,tags -S 'tags=[tagA || tagC || tagD]'
1302 LV LV Tags
1303 lvol2 tagA,tagC,tagD
1304 lvol0 tagA,tagB
1305
1306 To match a set with no items, use "" to denote this (note that we have
1307 output compaction enabled so the "LV Tags" column is not displayed in
1308 the example below because it's blank and so it gets compacted).
1309
1310 # lvs -o name,tags -S 'tags=""'
1311 LV
1312 lvol4
1313 lvol3
1314 lvol1
1315
1316 # lvs -o name,tags -S 'tags!=""'
1317 LV LV Tags
1318 lvol2 tagA,tagC,tagD
1319 lvol0 tagA,tagB
1320
1321 When doing selection based on time fields, we can use either standard,
1322 absolute or freeform time expressions in selection criteria. Examples
1323 below are using standard forms.
1324
1325 # lvs -o name,time
1326 LV CTime
1327 lvol4 2016-09-09 16:57:44 +0200
1328 lvol3 2016-09-09 16:56:48 +0200
1329 lvol2 2016-09-09 16:55:12 +0200
1330 lvol1 2016-08-29 12:53:36 +0200
1331 lvol0 2016-08-29 10:15:17 +0200
1332
1333 # lvs -o name,time -S 'time since "2016-09-01"'
1334 LV CTime
1335 lvol4 2016-09-09 16:57:44 +0200
1336 lvol3 2016-09-09 16:56:48 +0200
1337 lvol2 2016-09-09 16:55:12 +0200
1338
1339 # lvs -o name,time -S 'time since "2016-09-09 16:56"'
1340 LV CTime
1341 lvol4 2016-09-09 16:57:44 +0200
1342 lvol3 2016-09-09 16:56:48 +0200
1343
1344 # lvs -o name,time -S 'time since "2016-09-09 16:57:30"'
1345 LV CTime
1346 lvol4 2016-09-09 16:57:44 +0200
1347
1348 # lvs -o name,time \
1349 -S 'time since "2016-08-29" && time until "2016-09-09 16:55:12"'
1350 LV CTime
1351 lvol2 2016-09-09 16:55:12 +0200
1352 lvol1 2016-08-29 12:53:36 +0200
1353 lvol0 2016-08-29 10:15:17 +0200
1354
1355 # lvs -o name,time \
1356 -S 'time since "2016-08-29" && time before "2016-09-09 16:55:12"'
1357 LV CTime
1358 lvol1 2016-08-29 12:53:36 +0200
1359 lvol0 2016-08-29 10:15:17 +0200
1360
1361 Time operators have synonyms: ">=" for since, "<=" for until, ">" for
1362 "after" and "<" for "before".
1363
1364 # lvs -o name,time \
1365 -S 'time >= "2016-08-29" && time <= "2016-09-09 16:55:30"'
1366 LV CTime
1367 lvol2 2016-09-09 16:55:12 +0200
1368 lvol1 2016-08-29 12:53:36 +0200
1369 lvol0 2016-08-29 10:15:17 +0200
1370
1371 # lvs -o name,time \
1372 -S 'time since "2016-08-29" && time < "2016-09-09 16:55:12"'
1373 LV CTime
1374 lvol1 2016-08-29 12:53:36 +0200
1375 lvol0 2016-08-29 10:15:17 +0200
1376
1377 Example below demonstrates using absolute time expression.
1378
1379 # lvs -o name,time --config report/time_format="%s"
1380 LV CTime
1381 lvol4 1473433064
1382 lvol3 1473433008
1383 lvol2 1473432912
1384 lvol1 1472468016
1385 lvol0 1472458517
1386
1387 # lvs -o name,time -S 'time since @1473433008'
1388 LV CTime
1389 lvol4 2016-09-09 16:57:44 +0200
1390 lvol3 2016-09-09 16:56:48 +0200
1391
1392 Examples below demonstrates using freeform time expressions.
1393
1394 # lvs -o name,time -S 'time since "2 weeks ago"'
1395 LV CTime
1396 lvol4 2016-09-09 16:57:44 +0200
1397 lvol3 2016-09-09 16:56:48 +0200
1398 lvol2 2016-09-09 16:55:12 +0200
1399 lvol1 2016-08-29 12:53:36 +0200
1400 lvol0 2016-08-29 10:15:17 +0200
1401
1402 # lvs -o name,time -S 'time since "1 week ago"'
1403 LV CTime
1404 lvol4 2016-09-09 16:57:44 +0200
1405 lvol3 2016-09-09 16:56:48 +0200
1406 lvol2 2016-09-09 16:55:12 +0200
1407
1408 # lvs -o name,time -S 'time since "2 weeks ago"'
1409 LV CTime
1410 lvol1 2016-08-29 12:53:36 +0200
1411 lvol0 2016-08-29 10:15:17 +0200
1412
1413 # lvs -o name,time -S 'time before "1 week ago"'
1414 LV CTime
1415 lvol1 2016-08-29 12:53:36 +0200
1416 lvol0 2016-08-29 10:15:17 +0200
1417
1418 # lvs -o name,time -S 'time since "68 hours ago"'
1419 LV CTime
1420 lvol4 2016-09-09 16:57:44 +0200
1421 lvol3 2016-09-09 16:56:48 +0200
1422 lvol2 2016-09-09 16:55:12 +0200
1423
1424 # lvs -o name,time -S 'time since "1 year 3 months ago"'
1425 LV CTime
1426 lvol4 2016-09-09 16:57:44 +0200
1427 lvol3 2016-09-09 16:56:48 +0200
1428 lvol2 2016-09-09 16:55:12 +0200
1429 lvol1 2016-08-29 12:53:36 +0200
1430 lvol0 2016-08-29 10:15:17 +0200
1431
1432
1433 Command log reporting
1434 As described in categorization based on reporting facility section at
1435 the beginning of this document, both report-oriented and processing-
1436 oriented LVM commands can report the command log if this is enabled
1437 with log/report_command_log configuration setting. Just like any other
1438 report, we can set the set of fields to display (log/command_log_cols)
1439 and to sort by (log/command_log_sort) for this report.
1440
1441 # lvmconfig --type full log/report_command_log log/command_log_cols \
1442 log/command_log_sort log/command_log_selection
1443 report_command_log=1
1444 command_log_cols="log_seq_num,log_type,log_context,log_object_type,
1445 log_object_name,log_object_group,log_message,
1446 log_errno,log_ret_code"
1447 command_log_sort="log_seq_num"
1448 command_log_selection="!(log_type=status && message=success)"
1449
1450
1451 # lvs
1452 Logical Volume
1453 ==============
1454 LV LSize Cpy%Sync
1455 lvol1 4.00m 100.00
1456 lvol0 4.00m
1457
1458 Command Log
1459 ===========
1460 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1461
1462 As you can see, the command log is empty (it contains only field
1463 names). By default, LVM uses selection on the command log report and
1464 this case no row matched the selection criteria, see also log report
1465 specifics section in this document for more information. We're display‐
1466 ing complete log report in the example below where we can see that both
1467 LVs lvol0 and lvol1 were successfully processed as well as the VG vg
1468 they are part of.
1469
1470 # lvmconfig --type full log/command_log_selection
1471 command_log_selection="all"
1472
1473 # lvs
1474 Logical Volume
1475 ==============
1476 LV LSize Cpy%Sync
1477 lvol1 4.00m 100.00
1478 lvol0 4.00m
1479
1480 Command Log
1481 ===========
1482 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1483 1 status processing lv lvol0 vg success 0 1
1484 2 status processing lv lvol1 vg success 0 1
1485 3 status processing vg vg success 0 1
1486
1487 # lvchange -an vg/lvol1
1488 Command Log
1489 ===========
1490 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1491 1 status processing lv lvol1 vg success 0 1
1492 2 status processing vg vg success 0 1
1493
1494
1495 Handling multiple reports per single command
1496 To configure the log report directly on command line, we need to use
1497 --configreport option before we start any -o--options, -O--sort or
1498 -S--select that is targeted for log report.
1499
1500 # lvs -o lv_name,lv_size --configreport log -o log_object_type, \
1501 log_object_name,log_message,log_ret_code
1502 Logical Volume
1503 ==============
1504 LV LSize
1505 lvol1 4.00m
1506 lvol0 4.00m
1507
1508 Command Log
1509 ===========
1510 ObjType ObjName Msg RetCode
1511 lv lvol0 success 1
1512 lv lvol1 success 1
1513 vg vg success 1
1514
1515 The lvm fullreport, with or without log report, consists of several
1516 reports - the --configreport is also used to target particular subre‐
1517 port here.
1518
1519 Below is an extended example with lvm fullreport to illustrate combina‐
1520 tion of various options. The report output is in JSON format. Also, we
1521 configure "vg", "pvseg", "seg" and "log" subreport to contain only
1522 specified fields. For the "pvseg" subreport, we're intested only in PV
1523 names having "sda" in their name. For the "log" subreport we're
1524 intested only in log lines related to either "lvol0" object or object
1525 having "sda" in its name. Also, for the log subreport we define order‐
1526 ing to be based on "log_object_type" field.
1527
1528 # lvm fullreport --reportformat json \
1529 --configreport vg -o vg_name,vg_size \
1530 --configreport pvseg -o pv_name,pvseg_start \
1531 -S 'pv_name=~sda' \
1532 --configreport seg -o lv_name,seg_start \
1533 --configreport log -o log_object_type,log_object_name \
1534 -O log_object_type \
1535 -S 'log_object_name=lvol0 || \
1536 log_object_name=~sda'
1537 {
1538 "report": [
1539 {
1540 "vg": [
1541 {"vg_name":"vg", "vg_size":"200.00m"}
1542 ]
1543 ,
1544 "pv": [
1545 {"pv_name":"/dev/sda", "vg_name":"vg"},
1546 {"pv_name":"/dev/sdb", "vg_name":"vg"}
1547 ]
1548 ,
1549 "lv": [
1550 {"lv_name":"lvol0", "vg_name":"vg"},
1551 {"lv_name":"lvol1", "vg_name":"vg"}
1552 ]
1553 ,
1554 "pvseg": [
1555 {"pv_name":"/dev/sda", "pvseg_start":"0"},
1556 {"pv_name":"/dev/sda", "pvseg_start":"1"},
1557 {"pv_name":"/dev/sda", "pvseg_start":"2"},
1558 {"pv_name":"/dev/sda", "pvseg_start":"3"}
1559 ]
1560 ,
1561 "seg": [
1562 {"lv_name":"lvol0", "seg_start":"0 "},
1563 {"lv_name":"lvol1", "seg_start":"0 "}
1564 ]
1565 }
1566 ]
1567 ,
1568 "log": [
1569 {"log_object_type":"lv", "log_object_name":"lvol0"},
1570 {"log_object_type":"lv", "log_object_name":"lvol0"},
1571 {"log_object_type":"pv", "log_object_name":"/dev/sda"},
1572 {"log_object_type":"pv", "log_object_name":"/dev/sda"},
1573 ]
1574 }
1575
1576
1577 Report extensions for LVM shell
1578 As already stated in log report coverage paragraph under log report
1579 specifics in this documentation, when using LVM shell the log report
1580 coverage is wider. There's also special command designed to query last
1581 command's log report in the LVM shell - the lastlog command.
1582
1583 The example below illustrates a situation where we called lvs command.
1584 After that, we inspected the log report with the lastlog, without any
1585 selection so all the log report is displayed on output. Then we called
1586 lastlog further, giving various selection criteria. Then we ran unknown
1587 LVM command "abc" for which the log report displays appropriate failure
1588 state.
1589
1590 # lvm
1591 lvm> lvs
1592 Logical Volume
1593 ==============
1594 LV LSize Cpy%Sync
1595 lvol1 4.00m 100.00
1596 lvol0 4.00m
1597
1598 Command Log
1599 ===========
1600 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1601 1 status processing lv lvol0 vg success 0 1
1602 2 status processing lv lvol1 vg success 0 1
1603 3 status processing vg vg success 0 1
1604 4 status shell cmd lvs success 0 1
1605
1606 lvm> lastlog
1607 Command Log
1608 ===========
1609 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1610 1 status processing lv lvol0 vg success 0 1
1611 2 status processing lv lvol1 vg success 0 1
1612 3 status processing vg vg success 0 1
1613 4 status shell cmd lvs success 0 1
1614
1615 lvm> lastlog -S log_object_type=lv
1616 Command Log
1617 ===========
1618 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1619 1 status processing lv lvol0 vg success 0 1
1620 2 status processing lv lvol1 vg success 0 1
1621
1622 lvm> lastlog -S log_context=shell
1623 Command Log
1624 ===========
1625 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1626 4 status shell cmd lvs success 0 1
1627
1628 lvm> abc
1629 Command Log
1630 ===========
1631 Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1632 1 error shell cmd abc No such command 'abc'. Try 'help'. -1 0
1633 2 status shell cmd abc failure -1 2
1634
1635
1637 lvm (8), lvmconfig (8), lvm fullreport (8)
1638
1639
1640
1641Red Hat, Inc LVM TOOLS 2.03.06(2) (2019-10-23) LVMREPORT(7)