C.5. Selection Criteria Display Examples
This section provides a series of examples showing how to use selection criteria for LVM display commands. The examples in this section use a system configured with LVM volumes that yield the following output when selection criteria are not used.
# lvs -a -o+layout,role
LV VG Attr LSize Pool Origin Data% Meta% Layout Role
root f1 -wi-ao---- 9.01g linear public
swap f1 -wi-ao---- 512.00m linear public
[lvol0_pmspare] vg ewi------- 4.00m linear private, \
pool,spare
lvol1 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public
lvol2 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public, \
origin, \
thinorigin
lvol3 vg Vwi---tz-k 1.00g pool lvol2 thin,sparse public, \
snapshot, \
thinsnapshot
pool vg twi-aotz-- 100.00m 0.00 1.07 thin,pool private
[pool_tdata] vg Twi-ao---- 100.00m linear private, \
thin,pool, \
data
[pool_tmeta] vg ewi-ao---- 4.00m linear private, \
thin,pool, \
metadata
The following command displays all logical volumes with "lvol[13]" in their name, using a regular expression to specify this.
# lvs -a -o+layout,role -S 'lv_name=~lvol[13]'
LV VG Attr LSize Pool Origin Data% Layout Role
lvol1 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public
lvol3 vg Vwi---tz-k 1.00g pool lvol2 thin,sparse public,snapshot,thinsnapshot
The following command displays all logical volumes greater than 500 megabytes in size.
# lvs -a -o+layout,role -S 'lv_size>500m'
LV VG Attr LSize Pool Origin Data% Layout Role
root f1 -wi-ao---- 9.01g linear public
swap f1 -wi-ao---- 512.00m linear public
lvol1 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public
lvol2 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public,origin,thinorigin
lvol3 vg Vwi---tz-k 1.00g pool lvol2 thin,sparse public,snapshot, \
thinsnapshot
The following command displays all logical volumes that include
thin
as a logical volume role, indicating that the logical volume is used in constructing a thin pool. This example uses braces ({}) to indicate a subset in the display.
# lvs -a -o+layout,role -S 'lv_role={thin}'
LV VG Attr LSize Layout Role
[pool_tdata] vg Twi-ao---- 100.00m linear private,thin,pool,data
[pool_tmeta] vg ewi-ao---- 4.00m linear private,thin,pool,metadata
The following command displays all usable top-level logical volumes, which are the logical volumes with a role of "public". If you do not specify braces ({}) in a string list to indicate a subset, it is assumed by default; specifying
lv_role=public
is equivalent to specifying lv_role={public}
.
# lvs -a -o+layout,role -S 'lv_role=public'
LV VG Attr LSize Pool Origin Data% Layout Role
root f1 -wi-ao---- 9.01g linear public
swap f1 -wi-ao---- 512.00m linear public
lvol1 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public
lvol2 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public,origin,thinorigin
lvol3 vg Vwi---tz-k 1.00g pool lvol2 thin,sparse public,snapshot,thinsnapshot
The following command displays all logical volumes with a thin layout.
# lvs -a -o+layout,role -S 'lv_layout={thin}'
LV VG Attr LSize Pool Origin Data% Meta% Layout Role
lvol1 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public
lvol2 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public,origin, \
thinorigin
lvol3 vg Vwi---tz-k 1.00g pool lvol2 thin,sparse public,snapshot, \
thinsnapshot
pool vg twi-aotz-- 100.00m 0.00 1.07 thin,pool private
The following command displays all logical volumes with a layout field that matches "sparse,thin" exactly. Note that it is not necessary to specify the string list members for the match to be positive.
# lvs -a -o+layout,role -S 'lv_layout=[sparse,thin]'
LV VG Attr LSize Pool Origin Data% Layout Role
lvol1 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public
lvol2 vg Vwi-a-tz-- 1.00g pool 0.00 thin,sparse public,origin,thinorigin
lvol3 vg Vwi---tz-k 1.00g pool lvol2 thin,sparse public,snapshot,thinsnapshot
The following command displays the logical volume names of the logical volumes that are thin, sparse logical volumes. Note that the list of fields used for selection criteria do not need to be the same as the list of fields to display.
# lvs -a -o lv_name -S 'lv_layout=[sparse,thin]'
LV
lvol1
lvol2
lvol3