To display the LVM physical volume on a system, you can use either the pvs command or the pvscan command as the root user. For example, the below commands create a physical volume on /dev/sdc1 partition and views the information about it in the next pvs command.
$ sudo pvcreate /dev/sdc1 ### Make sdc1 an LVM physical volume Physical volume “/dev/sdc1” successfully created
$ sudo pvs ### View physical LVM partitions PV VG Fmt Attr PSize PFree /dev/sdc1 lvm2 a-- 3.73g 3.73g
To implement LVMs, we create three objects:
- Physical volumes: This represents the raw disk space as disk partitions. When we use partitions, the partition type should be set to Linux LVM with an ID of 8E using the fdisk partitioning tool.
- Volume groups: This aggregates physical volumes together so that the disk space can be consumed to logical volumes.
- Logical volumes: This represents the block device that can be shared. It consumes space that is allocated from volume groups.
pvs Command Examples
1. To display the PV info:
# pvs
2. To see all the information:
# pvs --all
3. To align the output:
# pvs --alligned
4. To add an “LVM2_” prefix plus the field name to the output:
# pvs --nameprefixes
5. To suppress the headings:
# pvs --noheadings
6. To suppress the suffix on output sizes:
# pvs --nosuffix
7. To comma-separated ordered list of columns:
# pvs -o # pvs --options
8. To produces one line of output for each contiguous allocation:
# pvs --segments
9. To comma-separated ordered list of columns to sort by:
# pvs -O # pvs --sort
10. To output columns as rows:
# pvs --rows
11. To use the string to separate each column:
# pvs --separator ,
12. To produce output immediately without sorting or aligning the columns properly:
# pvs --unbuffered
13. To All sizes are output in these units:
# pvs --units hHbBsSkKmMgGtTpPeE
14. To get the help for pvs:
# pvs --help
15. To get the version:
# pvs --version
16. To set to verbose mode:
# pvs -v # pvs --verbose