LVMREPORT(7)
โจ lvmreport(7) โจ
๐ NAME ๐
lvmreport โ LVM reporting and related features
๐ธ DESCRIPTION ๐ธ
LVM uses one single reporting infrastructure, and it sets the standard for what LVM commands spit out. It also gives you a whole buffet of configuration settings and command line options so you can customize the report and filter its output. Basically: the report game is unified, bestie. ๐
๐ซถ USAGE ๐ซถ
โจ Categorization based on reporting facility โจ
Based on functionality, commands that use the reporting infrastructure split into two groups:
๐ Report-oriented commands
These commands report the current LVM state; their main job is to show that info in a concise way. To keep things clear, this report is called the main report. The report-only command set includes: pvs, vgs, lvs, pvdisplay, vgdisplay, lvdisplay, lvm devtypes, lvm fullreport. For more on the main report, see Main report specifics.
๐ ๏ธ Processing-oriented commands
These commands are the ones changing LVM state, and they don't have any main report like report-oriented commands do. They just do some kind of processing. The processing-oriented command set includes: pvcreate, vgcreate, lvcreate, pvchange, vgchange, lvchange, pvremove, vgremove, lvremove, pvresize, vgextend, vgreduce, lvextend, lvreduce, lvresize, lvrename, pvscan, vgscan, lvscan, pvmove, vgcfgbackup, vgck, vgconvert, vgexport, vgimport, vgmknodes.
If it's enabled, the so-called log report is either shown all by itself (for processing-oriented commands) or shown on top of the main report (for report-oriented commands). The log report contains a log of operations, messages, and per-object status with complete object identification collected while the LVM command runs. See Log report specifics for more info about this report type.
๐ง Terms ๐ง
When we talk about reporting functionality and features in this text, we're gonna use the terms row and column. By row, we mean a series of values reported for a single entity (like a single PV, VG, or LV). Each value in that row then belongs to a column of a certain type. Columns have column headings, which are short descriptions for the columns. Columns are referenced by column names. Also, just so you know: this text uses the term field interchangeably with the term column. Most of the time, column gets abbreviated as col in configuration.
๐ Common report configuration settings and command line options ๐
There are common configuration settings and command line options that apply to both the main report and the log report. The lists below contain all of them, split into groups based on how you use them.
๐ Common configuration settings ๐
Changing report output format, composition and other output modifiers:
global/suffixglobal/unitsreport/alignedreport/binary_values_as_numericreport/columns_as_rowsreport/compact_outputreport/compact_output_colsreport/headingsreport/list_item_separatorreport/mark_hidden_devicesreport/output_formatreport/prefixesreport/quotedreport/separatorreport/time_formatreport/two_word_unknown_device
Special settings:
report/buffered
This document does not describe these settings in more detail โ if you need detailed info, including the values accepted for the settings, please run lvmconfig --type default --withcomments <setting>. There are more configuration settings besides the common set listed above, but they're specific to either the main report or the log report; see main report specifics and log report specifics for those settings. Besides configuring reports globally with configuration settings, there are also command line options you can use to extend, override, or further specify the report configuration.
๐ซ Common command line options ๐ซ
Definition of the set of fields to use
-o|--options FieldSetโ Field set to use. See main report specifics and log report specifics for info about field sets configured with global configuration settings that this option overrides.-o|--options +FieldSetโ Fields to include in the current field set. See main report specifics and log report specifics for info about field sets configured with global configuration settings that this option extends.-o|--options -FieldSetโ Fields to exclude from the current field set. See main report specifics and log report specifics for info about field sets configured with global configuration settings that this option reduces.-o|--options #FieldSetโ Compaction of unused fields. Overrides thereport/compact_output_colsconfiguration setting.
Sorting
-O|--sort +FieldSetโ Fields to sort by in ascending order. See main report specifics and log report specifics for info about field sets configured with global configuration settings that this option overrides.-O|--sort -FieldSetโ Fields to sort by in descending order. See main report specifics and log report specifics for info about field sets configured with global configuration settings that this option overrides.
Selection
-S|--select Selectionโ Define selection criteria for report output. For the log report, this also overrides thelog/command_log_selectionconfiguration setting; see also log report specifics.
Changing output format and composition
--reportformatโ Overrides thereport/output_formatconfiguration setting.--alignedโ Overrides thereport/alignedconfiguration setting.--binaryโ Overrides thereport/binary_values_as_numericconfiguration setting.--headingsโ Overrides thereport/headingsconfiguration settings.--nameprefixesโ Overrides thereport/prefixesconfiguration setting.--noheadingsโ Overrides thereport/headingsconfiguration setting.--nosuffixโ Overrides theglobal/suffixconfiguration setting.--rowsโ Overrides thereport/columns_as_rowsconfiguration setting.--separatorโ Overrides thereport/separatorconfiguration setting.--unitsโ Overrides theglobal/unitsconfiguration setting.--unquotedโ Overrides thereport/quotedconfiguration setting.
Special options
--configreport ReportNameโ This defines the ReportName for which any subsequent-o|--options,-O|--sortor-S|--selectapplies to. See also Main report specifics and Log report specifics for possible ReportName values.--logonlyโ When an LVM command contains both a main report and a log report, this option suppresses the main report output and causes the log report output to be displayed only.--unbufferedโ Overrides thereport/bufferedconfiguration setting.
The FieldSet mentioned in the lists above is a set of field names where each field name is delimited by the "," character. Field set definition, sorting and selection may be repeated on the command line (-o+/-o- includes/excludes fields to/from the current list; for all the other repeatable options, the last value typed for the option on the command line is used). The Selection is a string with selection criteria; see also the Selection paragraph below for more info about constructing these criteria.
๐ Main report specifics ๐
The main report currently includes these distinct subtypes, referenced by their name โ ReportName as listed below. The command in parentheses is a representative command that uses the main report subtype by default. Each subtype has its own configuration setting for global field set definition as well as sort field definition (listed below each individual ReportName):
pvโ representing report about Physical Volumes (pvs)report/pvs_colsreport/pvs_sort
pvsegโ representing report about Physical Volume Segments (pvs --segments)report/pvsegs_colsreport/pvsegs_sort
vgโ representing report about Volume Groups (vgs)report/vgs_colsreport/vgs_sort
lvโ representing report about Logical Volumes (lvs)report/lvs_colsreport/lvs_sort
segโ representing report about Logical Volume Segments (lvs --segments)report/segs_colsreport/segs_sort
fullโ representing report combining all of the above as a whole (lvm fullreport)report/pvs_cols_fullreport/pvs_sort_fullreport/pvsegs_cols_fullreport/pvsegs_sort_fullreport/vgs_cols_fullreport/vgs_sort_fullreport/lvs_cols_fullreport/lvs_sort_fullreport/segs_cols_fullreport/segs_sort_full
devtypeโ representing report about device types (lvm devtypes)report/devtypes_colsreport/devtypes_sort
Use pvs, vgs, lvs -o help or lvm devtypes -o help to get the complete list of fields that you can use for the main report. The list of fields in the help output is separated into groups based on which report type they belong to. Note that LVM can change the final report type used if fields from different groups are combined together. Some of these combinations are not allowed, in which case LVM will issue an error.
okay bestie, so recap time is OVER, we're jumping straight back in ๐
For every main report subtype except full, you do not have to use --configreport ReportName to say which report your later -o, -O or -S options apply to โ they just apply to the one and only main report type, no confusion, no drama. And rn, lvm fullreport is literally the only command with more than one main report subtype in it. So --configreport? Chef's kiss for full report specifically, when you wanna set up each of its subreports in a totally different way. โจ
๐ชต Log report specifics
You turn the log report on with the log/report_command_log configuration setting โ and ngl it's disabled by default, so don't come crying when nothing shows up ๐. The log report holds a log grabbed while an LVM command was executing, and then it's displayed just like every other report you already know from the main report. There's only one log report subtype, and here it is with its config settings for fields, sorting and selection:
log representing log report
โ log/command_log_cols
โ log/command_log_sort
โ log/command_log_selection
You always need --configreport log together with -o|--options, -O|--sort or -S|--select if you wanna override configuration settings straight up on the command line for the log report. And compared to the main report, the log report also has a configuration option for selection โ log/command_log_selection โ on top of the usual config settings for report fields and sorting. It's there for convenience, so you don't have to slap -S|--select on the command line every single time you run an LVM command and want the same selection criteria on the log report. The default selection criteria used for the log report is log/command_log_selection="!(log_type=status && message=success)". Translation? By default the log report does not show status messages about successful operations โ it only shows rows with error, warning, print-type messages, and messages about failure states. Wanna see the unfiltered command log? Use the "all" value for the selection. More on that in the log report content below ๐
๐ซง Log report coverage
Currently, when LVM commands are run directly (so not in the LVM shell), the log report covers the command's processing stage โ that is, the moment when LVM entities get iterated and processed one by one. It does not cover command initialization or finalization. If a message is issued outside the log report's coverage, it goes straight to output, bypassing the log report entirely. And by default? That's standard error output for error and warning messages, and standard output for common print-like messages.
When LVM commands are run in the LVM shell, though, the log report covers the whole LVM command execution โ processing, initialization and finalization included. So from that angle, the log report coverage is complete for executed LVM commands ๐. But heads up: there are still a few moments when the LVM shell needs to initialize itself before it even enters the main loop where it executes LVM commands. Also there's a moment where the LVM shell needs to get the log report properly ready for the next command executed in the shell, and then, after the command runs, the shell needs to display the log report for that recently executed command. If there's a failure or any other message issued during that time, LVM will bypass the log report and display messages on output directly. ๐
For these reasons, and for completeness: it is not possible to rely fully on the log report as the only indicator of an LVM command's status, or as the only place where all messages issued during LVM command execution are collected. You always need to check the non-report output to determine whether the command failed outside the log report's coverage. Fr fr, check both.
To help with this, LVM can separate output which you can then redirect to any custom file descriptor you prepare before running an LVM command or LVM shell โ and then use those file descriptors for different kinds of output by defining environment variables with file descriptor numbers. See also the LVM_OUT_FD, LVM_ERR_FD and LVM_REPORT_FD environment variable description in the lvm(8) man page. ๐
Also note: by default, reports use the same file descriptor as common print-like messages, which is standard output. If you plan to use the log report in your scripts or any external tool, you should use LVM_OUT_FD, LVM_ERR_FD and LVM_REPORT_FD to separate all output types to different file descriptors. For example, with bash, that would be:
LVM_OUT_FD=3 LVM_ERR_FD=4 LVM_REPORT_FD=5 <lvm command>
3>out_file 4>err_file 5>report_file
Here, <lvm_command> is either a direct LVM command or the LVM shell. The three output types can then be collected in separate files. Obsessed with the tidiness tbh ๐
๐งพ Log report content
Each item in the log report consists of the following set of fields, providing various information:
Basic information (mandatory):
log_seq_numโ Item sequence number. It's unique for each log item and it increases in the order of the log items as they appeared during LVM command execution.log_typeโ Type of log for the item. Currently, these types are used:statusโ for any status information that is loggedprintโ for any common message printed while the log is collectederrorโ for any error message printed while the log is collectedwarnโ for any warning message printed while the log is collected
log_contextโ Context of the log for the item. Currently, two contexts are identified:shellโ for the log collected in the outermost code before and after executing concrete LVM commandsprocessingโ for the log collected while processing LVM entities during LVM command execution
Message (mandatory):
log_messageโ Any message associated with the current item. For thestatuslog type, the message contains eithersuccessorfailure, denoting current state. Forprint,errorandwarnlog types, the message contains the exact message of that type that got issued.
Object information (used only if applicable):
log_object_typefield โ Type of the object processed. Currently, these object types are recognized:cmdโ for command as a wholeorphanโ for processing group of PVs not in any VG yetpvโ for PV processinglabelโ for direct PV label processing (without VG metadata)vgโ for VG processinglvโ for LV processing
log_object_nameโ Name of the object processed.log_object_idโ ID of the object processed.log_object_groupโ A group where the processed object belongs to.log_object_group_idโ An ID of a group where the processed object belongs to.
Numeric status (used only if applicable):
log_errnoโ Error number associated with the current item.log_ret_codeโ Return code associated with the current item.
You can also run lvm --configreport log -o help to display the complete list of fields that you may use for the log report. Slay, a whole menu ๐ซถ
๐ฏ Selection
Selection is what you use for a report to display only rows that match selection criteria. Every row is displayed with the additional selected field (-o selected) showing 1 if the row matches the Selection and 0 otherwise. The selection criteria are a set of statements combined by logical and grouping operators. The statement consists of a field name for which a set of valid values is defined using comparison operators. For the complete list of field names you can use in selection, see the output of lvm -S help. That help output also contains the type of values each field displays, enclosed in brackets. โจ
๐ฃ List of operators recognized in selection criteria
Comparison operators (cmp_op):
=~โ matching regular expression.!~โ not matching regular expression.=โ equal to.!=โ not equal to.>=โ greater than or equal to.>โ greater than<=โ less than or equal to.<โ less than.
Binary logical operators (log_op):
&&โ all fields must match,โ all fields must match||โ at least one field must match#โ at least one field must match
Unary logical operators:
!โ logical negation
Grouping operators:
(โ left parenthesis)โ right parenthesis[โ list start]โ list end{โ list subset start}โ list subset end
๐งฎ Field types and selection operands
Field type restricts the set of operators and values that you may use with the field when defining selection criteria. You can see the field type for each field if you run lvm -S help, where you can find the type name enclosed in square brackets. Currently, LVM recognizes these field types in reports:
stringโ for set of characters (for each string field type, you can use eitherstringor regular expression โregexfor the value used in selection criteria)string listโ for set of stringsnumberโ for integer valuesizeโ for integer or floating point number with size unit suffix (see also thelvcreate(8)man page and the description for the-L|--sizeoption for the list of recognized suffixes)percentโ for floating point number with or without%suffix (e.g.50or50%)timeโ for time values
When using string list in selection criteria, there are several ways in which LVM can match string list fields from a report, depending on what list grouping operator is used and what item separator is used within that set of items. Also, note that the order of items does not matter here. ๐
- Matching all items in the string list field:
- and all items from selection, use
[ ]with","(or"&&"), e.g.["a","b","c"], - and any item from selection, use
[ ]with"#"(or"||"), e.g.["a"#"b"#"c"].
- and all items from selection, use
- Matching a subset of items in the string list field:
โ and when you want every single item from a selection, you wrap them in { } with "," (or "&&"), like this: {"a","b","c"},
โ and when you want any one of the items from a selection, use { } with "#" (or "||"), like this: {"a"#"b"#"c"}.
When you're dropping time into your selection criteria, LVM is so flexible โ it recognizes a bunch of time formats using standard, absolute or freeform expressions. Want examples of time expressions living inside selection criteria? Scroll to the EXAMPLES section, bestie. ๐
- Standard time format
โ date YYYY-MM-DD YYYY-MM, auto DD=1 YYYY, auto MM=01 and DD=01
โ time hh:mm:ss hh:mm, auto ss=0 hh, auto mm=0, auto ss=0
โ timezone +hh:mm or -hh:mm +hh or -hh
The full date/time specification is YYYY-MM-DD hh:mm:ss. Date/time parts may be omitted from right to left. And whenever parts are omitted, a range is assumed automatically with second granularity. For example:
"2015-07-07 9:51"
means range of "2015-07-07 9:51:00" โ "2015-07-07 9:51:59"
"2015-07"
means range of "2015-07-01 0:00:00" โ "2015-07-31 23:59:59"
"2015"
means range of "2015-01-01 0:00:00" โ "2015-12-31 23:59:59"
- Absolute time format โ absolute time is defined as the number of seconds since the Epoch (
1970:01:01 00:00 +00:00).
โ @seconds
- Freeform time format
โ weekday names ("Sunday" โ "Saturday" or abbreviated as "Sun" โ "Sat") โ labels for points in time ("noon", "midnight") โ labels for a day relative to current day ("today", "yesterday") โ points back in time with relative offset from today (N is a number)
"N" "seconds" / "minutes" / "hours" / "days" / "weeks" /
"years" "ago"
"N" "secs" / "mins" / "hrs" ... "ago"
"N" "s" / "m" / "h" ... "ago"
โ time specification either in hh:mm:ss format or with AM/PM suffixes โ month names ("January" โ "December" or abbreviated as "Jan" โ "Dec")
๐ธ Informal grammar specification ๐ธ
โ STATEMENT = column cmp_op VALUE | STATEMENT log_op STATEMENT | (STATEMENT) | !(STATEMENT)
โ VALUE = [VALUE log_op VALUE] For list-based types: string list. Matches all items in list. The log_op must always be of one type within the whole list value.
โ VALUE = {VALUE log_op VALUE} For list-based types: string list. Matches a subset of items in list. The log_op must always be of one type within the whole list value.
โ VALUE = value For scalar types: number, size, percent, string (or string regex). Also for list-based types: string list (in this case the value is a short form of {value}).
โจ EXAMPLES โจ
๐ Basic usage
We're kicking things off with the default configuration โ lvmconfig(8) is your bestie command for showing the configuration settings that are currently in use, including every setting related to reporting. We'll be using it all through the examples below to show the current configuration. ๐ซถ
# lvmconfig --type full global/units global/suffix \
report/output_format report/compact_output \
report/compact_output_cols report/aligned \
report/headings report/separator \
report/list_item_separator report/prefixes \
report/quoted report/columns_as_rows \
report/binary_values_as_numeric report/time_format \
report/mark_hidden_devices report/two_word_unknown_device \
report/buffered
units="h"
suffix=1
output_format="basic"
compact_output=0
compact_output_cols=""
aligned=1
headings=1
separator=" "
list_item_separator=","
prefixes=0
quoted=1
columns_as_rows=0
binary_values_as_numeric=0
time_format="%Y-%m-%d %T %z"
mark_hidden_devices=1
two_word_unknown_device=0
buffered=1
Also, we're starting from a simple LVM layout with two PVs (/dev/sda, /dev/sdb), a VG (vg) and two LVs (lvol0 and lvol1) in the VG. We're displaying all possible reports as single commands right here โ see also pvs(8), vgs(8), lvs(8) man pages for more info. The field set for each report type is configured with configuration settings, just like we already yapped about in the main report specifics section of this man page. ๐
# lvmconfig --type full report/pvs_cols report/pvs_sort \
report/pvsegs_cols report/pvsegs_sort report/vgs_cols \
report/vgs_sort report/lvs_cols report/lvs_sort \
report/segs_cols report/segs_sort
pvs_cols="pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
pvs_sort="pv_name"
pvsegs_cols="pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,
pvseg_start,pvseg_size"
pvsegs_sort="pv_name,pvseg_start"
vgs_cols="vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
vgs_sort="vg_name"
lvs_cols="lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,move_pv,
mirror_log,copy_percent,convert_lv"
lvs_sort="vg_name,lv_name"
segs_cols="lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
segs_sort="vg_name,lv_name,seg_start"
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda vg lvm2 a-- 100.00m 88.00m
/dev/sdb vg lvm2 a-- 100.00m 92.00m
# pvs --segments
PV VG Fmt Attr PSize PFree Start SSize
/dev/sda vg lvm2 a-- 100.00m 88.00m 0 1
/dev/sda vg lvm2 a-- 100.00m 88.00m 1 1
/dev/sda vg lvm2 a-- 100.00m 88.00m 2 1
/dev/sda vg lvm2 a-- 100.00m 88.00m 3 22
/dev/sdb vg lvm2 a-- 100.00m 92.00m 0 1
/dev/sdb vg lvm2 a-- 100.00m 92.00m 1 1
/dev/sdb vg lvm2 a-- 100.00m 92.00m 2 23
# vgs
VG #PV #LV #SN Attr VSize VFree
vg 2 2 0 wz--n- 200.00m 180.00m
# lvs
LV VG Attr LSize Pool Origin Move Log Cpy%Sync Convert
lvol0 vg -wi-a----- 4.00m
lvol1 vg rwi-a-r--- 4.00m 100.00
# lvs --segments
LV VG Attr #Str Type SSize
lvol0 vg -wi-a----- 1 linear 4.00m
lvol1 vg rwi-a-r--- 2 raid1 4.00m
We're going to use the report/lvs_cols and report/lvs_sort configuration settings to define our own list of fields to use and sort by โ different from the defaults. You can do this for the other reports the exact same way with the report/{pvs,pvsegs,vgs,seg}_{cols,sort} configuration settings. Also, real talk, in the example below we don't display the "lv_time" field even though we're using it for sorting โ and that's totally allowed. โจ
# lvmconfig --type full report/lvs_cols report/lvs_sort
lvs_cols="lv_name,lv_size,origin,pool_lv,copy_percent"
lvs_sort="-lv_time"
# lvs
LV LSize Origin Pool Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
You can use the -o|--options command line option to override the current configuration directly on the command line. ๐
# lvs -o lv_name,lv_size
LV LSize
lvol1 4.00m
lvol0 4.00m
# lvs -o+lv_layout
LV LSize Origin Pool Cpy%Sync Layout
lvol1 4.00m 100.00 raid,raid1
lvol0 4.00m linear
# lvs -o-origin
LV LSize Pool Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
# lvs -o lv_name,lv_size,origin -o+lv_layout -o-origin -O lv_name
LV LSize Layout
lvol0 4.00m linear
lvol1 4.00m raid,raid1
You can get all that same info with a single command where all the information about PVs, PV segments, LVs and LV segments is obtained per VG under a single VG lock for consistency โ see also the lvm fullreport(8) man page for more. The fullreport has its own configuration settings to define the field sets it uses, similar to the individual reports we showed above, except the configuration settings have a "_full" suffix now. This way, it's possible to configure different sets of fields to display and to sort by for individual reports and for the full report. ๐ฆ
# lvmconfig --type full report/pvs_cols_full \
report/pvs_sort_full report/pvsegs_cols_full \
report/pvsegs_sort_full report/vgs_cols_full \
report/vgs_sort_full report/lvs_cols_full \
report/lvs_sort_full report/segs_cols_full \
report/segs_sort_full
pvs_cols_full="pv_name,vg_name"
pvs_sort_full="pv_name"
pvsegs_cols_full="pv_name,pvseg_start,pvseg_size"
pvsegs_sort_full="pv_uuid,pvseg_start"
vgs_cols_full="vg_name"
vgs_sort_full="vg_name"
lvs_cols_full="lv_name,vg_name"
lvs_sort_full="vg_name,lv_name"
segs_cols_full="lv_name,seg_start,seg_size"
segs_sort_full="lv_uuid,seg_start"
# lvm fullreport
VG
vg
PV VG
/dev/sda vg
/dev/sdb vg
LV VG
lvol0 vg
lvol1 vg
PV Start SSize
/dev/sda 0 1
/dev/sda 1 1
/dev/sda 2 1
/dev/sda 3 22
/dev/sdb 0 1
/dev/sdb 1 1
/dev/sdb 2 23
LV Start SSize
lvol0 0 4.00m
lvol1 0 4.00m
๐ Automatic output compaction ๐
If you look at the lvs output above, you'll notice the report also contains fields where there's literally nothing to display (e.g. the columns under the "Origin" and "Pool" headings โ the "origin" and "pool_lv" fields). LVM can automatically compact report output so those fields don't make it into the final output. To turn this feature on and compact all the fields, use report/compact_output=1 in your configuration. ๐
# lvmconfig --type full report/compact_output
compact_output=1
# lvs
LV LSize Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
# lvs vg/lvol0
LV LSize
lvol0 4.00m
Or, alternatively, you can define exactly which fields should be compacted by configuring the report/compact_output_cols configuration setting (or the -o|--options # command line option). ๐
# lvmconfig --type full report/compact_output report/compact_output_cols
compact_output=0
compact_output_cols="origin"
# lvs
LV LSize Pool Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
# lvs vg/lvol0
LV LSize Pool
lvol0 4.00m
# lvs -o#pool_lv
LV LSize Origin Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
We'll be using report/compact_output=1 for all the examples that come after this. โญ
๐ Further formatting options ๐
By default, LVM displays sizes in reports in human-readable form โ meaning it uses the most suitable unit so it's easy to read. You can use the global/units configuration setting (or the --units option straight up on the command line) and the global/suffix configuration setting (or the --nosuffix command line option) to change that. ๐ง
# lvs --units b --nosuffix
LV LSize Cpy%Sync
lvol1 4194304 100.00
lvol0 4194304
Okay so if you wanna decide whether those report headings show up at all, that's the report/headings configuration setting doing the heavy lifting (or you can just slap --noheadings on the command line, same energy).
# lvs --noheadings
lvol1 4.00m 100.00
lvol0 4.00m
Sometimes it's so much better to spit the report out as key=value pairs, where the key is literally the field name. Flip between the normal output and that key=value glow-up with the report/prefixes configuration setting (or --nameprefixes on the command line). And bestie, that key=value output is the one you want for scripts and for other tools to parse without crying. Usually you also do NOT want headings when you're doing the key=value thing.
# lvs --noheadings --nameprefixes
LVM2_LV_NAME='lvol1' LVM2_LV_SIZE='4.00m' LVM2_COPY_PERCENT='100.00'
LVM2_LV_NAME='lvol0' LVM2_LV_SIZE='4.00m' LVM2_COPY_PERCENT=''
Wanna decide whether those quotation marks in the key=value pairs show up or not? That's report/quoted (or the --unquoted command line option).
# lvs --noheadings --nameprefixes --unquoted
LVM2_LV_NAME=lvol1 LVM2_LV_SIZE=4.00m LVM2_COPY_PERCENT=100.00
LVM2_LV_NAME=lvol0 LVM2_LV_SIZE=4.00m LVM2_COPY_PERCENT=
For even easier parsing, you can literally transpose the whole report so every column becomes a row in the output. That's the report/columns_as_rows configuration setting (or --rows on the command line).
# lvs --noheadings --nameprefixes --unquoted --rows
LVM2_LV_NAME=lvol1 LVM2_LV_NAME=lvol0
LVM2_LV_SIZE=4.00m LVM2_LV_SIZE=4.00m
LVM2_COPY_PERCENT=100.00 LVM2_COPY_PERCENT=
Wanna define your own field separator? Say less โ that's report/separator (or --separator).
# lvs --noheadings --nameprefixes --unquoted --separator " | "
LVM2_LV_NAME=lvol1 | LVM2_LV_SIZE=4.00m | LVM2_COPY_PERCENT=100.00
LVM2_LV_NAME=lvol0 | LVM2_LV_SIZE=4.00m | LVM2_COPY_PERCENT=
Heads up tho ๐ if you're using your own separator, the columns in the output are not aligned by default. So use the report/aligned configuration setting (or --aligned) and LVM will add extra spaces in the report to line everything up all pretty.
# lvs --separator " | "
LV | LSize | Cpy%Sync
lvol1 | 4.00m | 100.00
lvol0 | 4.00m |
# lvs --separator " | " --aligned
LV | LSize | Cpy%Sync
lvol1 | 4.00m | 100.00
lvol0 | 4.00m |
Okay let's show off one more field in the lvs report output ("lv_tags" in this example).
# lvs -o+lv_tags
LV LSize Cpy%Sync LV Tags
lvol1 4.00m 100.00
lvol0 4.00m tagA,tagB
See that "LV Tags" column? It's serving two list values, separated by the "," character for LV lvol0. If you need a different list item separator, use the report/list_item_separator configuration setting to define it.
# lvmconfig --type full report/list_item_separator
list_item_separator=";"
# lvs -o+tags
LV LSize Cpy%Sync LV Tags
lvol1 4.00m 100.00
lvol0 4.00m tagA;tagB
But for the rest of these examples let's still keep the original "," character for list_item_separator, okay? Consistency queen ๐
Any time values showing up in reports can be formatted with the report/time_format configuration setting. By default you get the complete date and time, timezone included, no notes.
# lvmconfig --type full report/time_format
time_format="%Y-%m-%d %T %z"
# lvs -o+time
LV LSize Cpy%Sync CTime
lvol1 4.00m 100.00 2016-08-29 12:53:36 +0200
lvol0 4.00m 2016-08-29 10:15:17 +0200
You can change the time format the same way you would with the date(1) command or the strftime(3) function (lvmconfig --type default --withcomments report/time_format will hand you the complete list of available formatting options, icon behavior). In the example below we went with %s for the number of seconds since Epoch (1970-01-01 UTC).
# lvmconfig --type full report/time_format
time_format="%s"
# lvs
LV Attr LSize Cpy%Sync LV Tags CTime
lvol1 rwi-a-r--- 4.00m 100.00 1472468016
lvol0 -wi-a----- 4.00m tagA,tagB 1472458517
Now, the lvs does not display hidden LVs by default โ to include them in the output you gotta use the -a|--all command line option. And the names for these hidden LVs get displayed inside square brackets.
# lvs -a
LV LSize Cpy%Sync
lvol1 4.00m 100.00
[lvol1_rimage_0] 4.00m
[lvol1_rmeta_0] 4.00m
[lvol1_rimage_1] 4.00m
[lvol1_rmeta_1] 4.00m
lvol0 4.00m
You can configure LVM to show those square brackets for hidden LVs or not, with the report/mark_hidden_devices configuration setting.
# lvmconfig --type full report/mark_hidden_devices
mark_hidden_devices=0
# lvs -a
LV LSize Cpy%Sync
lvol1 4.00m 100.00
lvol1_rimage_0 4.00m
lvol1_rmeta_0 4.00m
lvol1_rimage_1 4.00m
lvol1_rmeta_1 4.00m
lvol0 4.00m
Fr fr, it is not recommended to use LV marks for hidden devices to decide whether the LV is the one end users should use or not. Please, use the"lv_role"field instead, which can report whether the LV is"public"or"private". The private LVs are used by LVM only and should not be accessed directly by end users.
# lvs -a -o+lv_role
LV LSize Cpy%Sync Role
lvol1 4.00m 100.00 public
lvol1_rimage_0 4.00m private,raid,image
lvol1_rmeta_0 4.00m private,raid,metadata
lvol1_rimage_1 4.00m private,raid,image
lvol1_rmeta_1 4.00m private,raid,metadata
lvol0 4.00m public
Some of the reporting fields LVM reports are just binary at heart. For those fields you can display either a word representation of the value (this is the default) or a numeric value (0/1, or -1 if the value is undefined).
# lvs -o+lv_active_locally
LV LSize Cpy%Sync ActLocal
lvol1 4.00m 100.00 active locally
lvol0 4.00m active locally
And we can change how these binary values display with the report/binary_values_as_numeric configuration setting.
# lvmconfig --type full report/binary_values_as_numeric
binary_values_as_numeric=1
# lvs -o+lv_active_locally
LV LSize Cpy%Sync ActLocal
lvol1 4.00m 100.00 1
lvol0 4.00m 1
In certain cases you might find it way more useful to report full column names instead of abbreviated column names in report headings. To do that, use the report/headings=2 configuration setting (or --headings full or --headings 2 on the command line). The full column names are the exact names you also use in FieldSet for -o|--options. These names are unambiguous, have no spaces (one word only), and they also make it easier to match the output with the requested FieldSet:
# lvs -o+seg_start,seg_start_pe
LV VG LSize Cpy%Sync Start Start
lvol0 vg 4.00m 0 0
lvol1 vg 4.00m 100.00 0 0
# lvs --headings full -o+seg_start,seg_start_pe
lv_name vg_name lv_size copy_percent seg_start seg_start_pe
lvol0 vg 4.00m 0 0
lvol1 vg 4.00m 100.00 0 0
๐ฆ Changing output format ๐ฆ
LVM can output reports in different formats โ use the report/output_format configuration setting (or the --reportformat command line option) to switch that report output format around.
Currently, LVM supports these output formats:
"basic"(all the examples above use this one),"json","json_std".
For example:
# lvs -o lv_name,lv_size --reportformat json
{
"report": [
{
"lv": [
{"lv_name":"lvol1", "lv_size":"4.00m"},
{"lv_name":"lvol0", "lv_size":"4.00m"}
]
}
]
}
The json_std output format is more compliant with the JSON standard, and compared to the original json format:
- it does not use double quotes around numeric values,
- numeric values are always expressed as numbers, not reserved strings representing them (this also means that
report/binary_values_as_numeric=1setting is forced), - it uses
'null'for undefined numeric values, - it prints string list as a proper JSON array of strings instead of a single string.
Ngl, note that some configuration settings and command line options have no effect with certain report formats. For example, withjsonorjson_stdoutput, usingreport/alignedhas no effect (--aligned),report/headings(values0,1or2;--noheadingssets the value to0),report/columns_as_rows(--rows) orreport/buffered(--unbuffered). All these configuration settings and command line options are ignored if you're using thejsonorjson_stdreport output format. Yeah. They just don't hit the same, sorry.
๐ธ Selection ๐ธ
If you need to select only specific rows from a report, you can use LVM's report selection feature. Call lvm -S help and you get quick help on selection. That help contains a list of all fields that LVM can use in reports together with their types enclosed in square brackets. The example below contains a line from lvs -S help.
# lvs -S help
...
lv_size - Size of LV in current units. [size]
...
This line is telling you that the "lv_size" field is of "size" type. And if you look at the bottom of the help output, you'll see a section about "Selection operators" and its "Comparison operators".
# lvs -S help
...
Selection operators
-------------------
Comparison operators:
=~ - Matching regular expression. [regex]
!~ - Not matching regular expression. [regex]
= - Equal to. [number, size, percent, string, string list, time]
!= - Not equal to. [number, size, percent, string, string_list, time]
>= - Greater than or equal to. [number, size, percent, time]
> - Greater than. [number, size, percent, time]
<= - Less than or equal to. [number, size, percent, time]
< - Less than. [number, size, percent, time]
since - Since specified time (same as '>='). [time]
after - After specified time (same as '>'). [time]
until - Until specified time (same as '<='). [time]
before - Before specified time (same as '<'). [time]
...
So here you can match up the comparison operators you may use with the "lv_size" field, which is of type "size" โ these are =, !=, >=, >, <= and <. You can find the applicable comparison operators for other fields and other field types the exact same way, bestie ๐ซถ
To demonstrate selection functionality in LVM, we will create more LVs in addition to lvol0 and lvol1 used in our previous examples.
So when you're picking out size and percent fields you literally do NOT need to type units at all, bestie. For sizes, the default is "m" (for MiB) โ which is the exact same behaviour LVM commands already had when you specify sizes (think lvcreate -L, you know the one). For percent fields, "%" just gets assumed automatically if you didn't say it. And this next example is also serving how you can combine several criteria together. Obsessed.
# lvs -o name,size,snap_percent -S 'size=8m'
LV LSize
lvol2 8.00m
# lvs -o name,size,snap_percent -S 'size=8'
LV LSize
lvol2 8.00m
# lvs -o name,size,snap_percent -S 'size < 5000k'
LV LSize Snap%
lvol4 4.00m 24.61
lvol3 4.00m 5.08
lvol1 4.00m
lvol0 4.00m
# lvs -o name,size,snap_percent -S 'size < 5000k && snap_percent > 20'
LV LSize Snap%
lvol4 4.00m 24.61
# lvs -o name,size,snap_percent \
-S '(size < 5000k && snap_percent > 20%) || name=lvol2'
LV LSize Snap%
lvol4 4.00m 24.61
lvol2 8.00m
And yes โ you can run selection together with the processing-oriented commands too. Not just the report ones. It's giving versatility. ๐
# lvchange --addtag test -S 'size < 5000k'
Logical volume vg/lvol1 changed.
Logical volume vg/lvol0 changed.
Logical volume vg/lvol3 changed.
Logical volume vg/lvol4 changed.
# lvchange --deltag test -S 'tags = test'
Logical volume vg/lvol1 changed.
Logical volume vg/lvol0 changed.
Logical volume vg/lvol3 changed.
Logical volume vg/lvol4 changed.
๐ธ String lists and time fields go complex ๐ธ
LVM can recognize more complex values used in selection criteria for string list and time field types, no cap. For string lists, you can match the whole list strictly, or just a subset, or an intersection. Let's take the "lv_tags" field as our example โ we're selecting only the rows that contain "tagA" inside the tags field. We use { } to say "hey, we want a subset that matches". And if that subset only has one item? You can leave the { } out entirely. Slay.
# lvs -o name,tags -S 'tags={tagA}'
LV LV Tags
lvol2 tagA,tagC,tagD
lvol0 tagA,tagB
# lvs -o name,tags -S 'tags=tagA'
LV LV Tags
lvol2 tagA,tagC,tagD
lvol0 tagA,tagB
So for string list values, you can either match all the items in the string list value (that's with [ ]) or only a subset of items in the string list value (that's with { }). And then, on top of that, you can either match if all items in the string list selection criterion match (use "," or "&&" as the item delimiter) or if only a subset of items in the string list selection criterion match (use "#" or "||" as the item delimiter). Two whole axes of matching. The range. ๐ญ
# lvs -o name,tags -S 'tags={tagA}'
LV LV Tags
lvol0 tagA,tagB
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags={tagA || tagB}'
LV LV Tags
lvol0 tagA,tagB
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags={tagA && tagB}'
LV LV Tags
lvol0 tagA,tagB
# lvs -o name,tags -S 'tags={tagA || tagB || tagC}'
LV LV Tags
lvol0 tagA,tagB
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags={tagA && tagB && tagC}'
# lvs -o name,tags -S 'tags=[tagA]'
# lvs -o name,tags -S 'tags=[tagA || tagB]'
LV LV Tags
lvol0 tagA,tagB
# lvs -o name,tags -S 'tags=[tagA && tagB]'
LV LV Tags
lvol0 tagA,tagB
# lvs -o name,tags -S 'tags=[tagA || tagB || tagC]'
LV LV Tags
lvol0 tagA,tagB
# lvs -o name,tags -S 'tags=[tagA && tagB && tagC]'
๐ notice how some of those just print nothing โ that's the criteria matching literally zero rows, and that's valid, she's just picky.
You can also use regular expressions instead of simple strings inside the string list selection criteria. In that case the "=~" operator gets used instead of "=". And the string list grouping operators { } and [ ] are recognized here too. โจ
# lvs -o name,tags -S 'tags=~^t.*[ACD]$'
LV LV Tags
lvol0 tagA,tagB
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags=~{"^t.*[ACD]$"}'
LV LV Tags
lvol0 tagA,tagB
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags=~["^t.*[ACD]$"]'
LV LV Tags
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags=~{"^t.*[AC]$" || "^tag[D]$" }'
LV LV Tags
lvol0 tagA,tagB
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags=~["^t.*[AC]$" || "^tag[D]$" ]'
LV LV Tags
lvol2 tagA,tagC,tagD
# lvs -o name,tags -S 'tags=~["^t.*A$" && "^t.*B$" ]'
LV LV Tags
lvol0 tagA,tagB
# lvs -o name,tags -S 'tags!~["^t.*A$" && "^t.*B$" ]'
LV LV Tags
lvol1
lvol2 tagA,tagC,tagD
lvol3
lvol4
To match a set with no items, you use "" to denote that. And heads up: in the example below we have output compaction enabled, so the "LV Tags" column is not displayed โ because it's blank, which means it got compacted away. Bye column. ๐
# lvs -o name,tags -S 'tags=""'
LV
lvol4
lvol3
lvol1
# lvs -o name,tags -S 'tags!=""'
LV LV Tags
lvol2 tagA,tagC,tagD
lvol0 tagA,tagB
๐ฐ๏ธ Time to talk time fields ๐ฐ๏ธ
When you're doing selection based on time fields, you can use standard, absolute, or freeform time expressions inside your selection criteria. The examples below are using the standard forms, bestie.
# lvs -o name,time
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
# lvs -o name,time -S 'time since "2016-09-01"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
# lvs -o name,time -S 'time since "2016-09-09 16:56"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
# lvs -o name,time -S 'time since "2016-09-09 16:57:30"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
# lvs -o name,time \
-S 'time since "2016-08-29" && time until "2016-09-09 16:55:12"'
LV CTime
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
# lvs -o name,time \
-S 'time since "2016-08-29" && time before "2016-09-09 16:55:12"'
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
The time operators have synonyms, iconic behaviour honestly: ">=" for since, "<=" for until, ">" for "after" and "<" for "before".
# lvs -o name,time \
-S 'time >= "2016-08-29" && time <= "2016-09-09 16:55:30"'
LV CTime
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
# lvs -o name,time \
-S 'time since "2016-08-29" && time < "2016-09-09 16:55:12"'
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
And here's an absolute time expression in the wild. Look at those raw epoch numbers. so crunchy ๐
# lvs -o name,time --config report/time_format="%s"
LV CTime
lvol4 1473433064
lvol3 1473433008
lvol2 1473432912
lvol1 1472468016
lvol0 1472458517
# lvs -o name,time -S 'time since @1473433008'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
Examples below are demonstrating freeform time expressions. The vibes are immaculate.
# lvs -o name,time -S 'time since "2 weeks ago"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
# lvs -o name,time -S 'time since "1 week ago"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
# lvs -o name,time -S 'time since "2 weeks ago"'
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
# lvs -o name,time -S 'time before "1 week ago"'
LV CTime
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
# lvs -o name,time -S 'time since "68 hours ago"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
# lvs -o name,time -S 'time since "1 year 3 months ago"'
LV CTime
lvol4 2016-09-09 16:57:44 +0200
lvol3 2016-09-09 16:56:48 +0200
lvol2 2016-09-09 16:55:12 +0200
lvol1 2016-08-29 12:53:36 +0200
lvol0 2016-08-29 10:15:17 +0200
๐งพ Command log reporting ๐งพ
So, like we said in the categorization based on reporting facility section at the beginning of this document: both report-oriented and processing-oriented LVM commands can report the command log, if that's enabled with the log/report_command_log configuration setting. And just like any other report ever, we can set the fields to display (log/command_log_cols) and what to sort by (log/command_log_sort) for this report. Customization? We love her.
# lvmconfig --type full log/report_command_log log/command_log_cols \
log/command_log_sort log/command_log_selection
report_command_log=1
command_log_cols="log_seq_num,log_type,log_context,log_object_type,
log_object_name,log_object_group,log_message,
log_errno,log_ret_code"
command_log_sort="log_seq_num"
command_log_selection="!(log_type=status && message=success)"
# lvs
Logical Volume
==============
LV LSize Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
OK so as you can literally see, the command log contains no rows โ only field names. And why? Because by default, LVM uses selection on the command log report, and in this case no row matched the selection criteria. (See also the log report specifics section in this document for more on that.) In the example below we're displaying the complete log report, where we can see that both LVs lvol0 and lvol1, and the VG vg they're part of, were successfully processed. ๐ซถ
# lvmconfig --type full log/command_log_selection
command_log_selection="all"
# lvs
Logical Volume
==============
LV LSize Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
3 status processing vg vg success 0 1
# lvchange -an vg/lvol1
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol1 vg success 0 1
2 status processing vg vg success 0 1
โจ Handling multiple reports per single command โจ
okay so bestie, listen ๐ if you wanna configure the log report directly on the command line, there's one thing you simply cannot fumble: you have to use the --configreport option before you use any -o|--options, -O|--sort or -S|--select that's aimed at the log report. Order is everything, no cap. ๐ซถ
# lvs -o lv_name,lv_size --configreport log -o log_object_type, \
log_object_name,log_message,log_ret_code
Logical Volume
==============
LV LSize
lvol1 4.00m
lvol0 4.00m
Command Log
===========
ObjType ObjName Msg RetCode
lv lvol0 success 1
lv lvol1 success 1
vg vg success 1
The lvm fullreport โ whether or not it's carrying a log report โ is literally a whole stack of reports, so --configreport is also the move for targeting one particular subreport in there. ๐ฏ
Below is the extended example with lvm fullreport showing off a combination of various options. Output's in JSON format, obviously. We also set up the vg, pvseg, seg and log subreports so they only contain the fields we named. For the pvseg subreport we only care about PV names that have sda in their name. For the log subreport we only care about log lines that relate to either the lvol0 object or an object with sda in its name. And for that log subreport, we're defining the ordering to be based on the log_object_type field. ๐
# lvm fullreport --reportformat json \
--configreport vg -o vg_name,vg_size \
--configreport pvseg -o pv_name,pvseg_start \
-S 'pv_name=~sda' \
--configreport seg -o lv_name,seg_start \
--configreport log -o log_object_type,log_object_name \
-O log_object_type \
-S 'log_object_name=lvol0 || \
log_object_name=~sda'
{
"report": [
{
"vg": [
{"vg_name":"vg", "vg_size":"200.00m"}
]
,
"pv": [
{"pv_name":"/dev/sda", "vg_name":"vg"},
{"pv_name":"/dev/sdb", "vg_name":"vg"}
]
,
"lv": [
{"lv_name":"lvol0", "vg_name":"vg"},
{"lv_name":"lvol1", "vg_name":"vg"}
]
,
"pvseg": [
{"pv_name":"/dev/sda", "pvseg_start":"0"},
{"pv_name":"/dev/sda", "pvseg_start":"1"},
{"pv_name":"/dev/sda", "pvseg_start":"2"},
{"pv_name":"/dev/sda", "pvseg_start":"3"}
]
,
"seg": [
{"lv_name":"lvol0", "seg_start":"0 "},
{"lv_name":"lvol1", "seg_start":"0 "}
]
}
]
,
"log": [
{"log_object_type":"lv", "log_object_name":"lvol0"},
{"log_object_type":"lv", "log_object_name":"lvol0"},
{"log_object_type":"pv", "log_object_name":"/dev/sda"},
{"log_object_type":"pv", "log_object_name":"/dev/sda"},
]
}
๐ฆ Report extensions for LVM shell ๐ฆ
Like we already said in the log report coverage paragraph under log report specifics in this documentation โ when you're in the LVM shell, the log report coverage is wider. So much wider. ๐
And there's a whole special command made for querying the last command's log report while you're in the LVM shell: the lastlog command. Not me being obsessed with lastlog. ๐ญ
This example is giving peak shell energy: we called lvs, then peeked at the log report with lastlog with no selection at all, so the entire log report lands on your output. Then we called lastlog again with various selection criteria. Then we ran an unknown LVM command abc, and for that one the log report shows off the appropriate failure state. ๐
# lvm
lvm> lvs
Logical Volume
==============
LV LSize Cpy%Sync
lvol1 4.00m 100.00
lvol0 4.00m
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
3 status processing vg vg success 0 1
4 status shell cmd lvs success 0 1
lvm> lastlog
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
3 status processing vg vg success 0 1
4 status shell cmd lvs success 0 1
lvm> lastlog -S log_object_type=lv
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
1 status processing lv lvol0 vg success 0 1
2 status processing lv lvol1 vg success 0 1
lvm> lastlog -S log_context=shell
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg Errno RetCode
4 status shell cmd lvs success 0 1
lvm> abc
Command Log
===========
Seq LogType Context ObjType ObjName ObjGrp Msg โ
1 error shell cmd abc No such command 'abc'. Try 'help'.
2 status shell cmd abc failure
โ Errno RetCode
-1 0
-1 2
๐ SEE ALSO ๐
lvm(8)lvmconfig(8)lvm fullreport(8)lvcreate(8)lvs(8)pvs(8)vgs(8)date(1)strftime(3)
aaand that's a wrap on the whole page, bestie!! ๐ Red Hat, Inc., this is LVM TOOLS 2.03.44(2), dated 2026-10-27, and you just finished LVMREPORT(7). go forth and report responsibly โจ๐ ๐ฆ
๐ฆ where this page comes from
- arch rolling: lvm2 2.03.44-1 ยท GPL-2.0-only AND LGPL-2.1-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms