System and processes
The lvs command
Shows a column summary of the LVM logical volumes.
Most useful options
-a, --allIncludes internal volumes, such as mirror parts, which cannot be mounted on their own-o, --options <campos>Chooses the columns to show. With -o help you see the full list of fields. A leading + adds to the default ones-O, --sort <campos>Sorts by the given columns. A - before a column reverses its order--noheadingsRemoves the header line, useful when filtering the output with grep or a script--units <unidad>Unit for sizes: h for human-readable, b for bytes, g or m for gigabytes or megabytesCopy-ready examples
$ sudo lvssummary of all logical volumes.$ sudo lvs -o lv_name,vg_name,lv_uuidpicks the name, group and identifier columns.$ sudo lvs --noheadings -o lv_nameonly the names, without a header, to use in a script.$ sudo lvs --separator ':' -o lv_name,vg_nameseparates the columns with colons instead of spaces.You can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- Without -a, internal volumes such as mirror parts do not appear.
- The available fields are the ones -o help lists on your system, not a fixed list.
- The normal output is aligned with spaces: to cut it in a script, use --separator.
FAQ
Which fields can I show?
The ones listed by lvs -o help. With -o field1,field2 you choose your own, and with -o +field you add columns to the default ones.
What is --units for?
It sets the unit of the sizes. With h they are human-readable, and with b, exact bytes. With --nosuffix you remove the suffix when passing the output to a script.
How do I sort the volumes by name in reverse?
With -O -lv_name: the dash in front of the column reverses its order.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course