6.1.1.3. Managing LVMs from the command line
Logical volumes are almost always used to contain filesystems (the other common use is to hold swapspace). In essence, an LV serves as a container for a filesystem. This has several ramifications:
Fedora's LVM2 system provides the lvm command for administration. Typing lvm by itself starts a specialized shell:
# lvm
lvm>
At the lvm> prompt, you can enter any of the subcommands shown in Table 6-1.
Table 6-1. LVM subcommands
LVM subcommand | Description |
---|---|
vgs | Displays details about volume groups (compact) |
pvs | Displays details about physical volumes (compact) |
lvs | Displays details about logical volumes (compact) |
vgdisplay | Displays details about volume groups (verbose) |
pvdisplay | Displays details about physical volumes (verbose) |
lvdisplay | Displays details about logical volumes (verbose) |
vgcreate | Creates a volume group |
vgremove | Removes a volume group |
pvcreate | Prepares a block device (such as a disk partition) for inclusion in a volume group by adding a disk label to the start of the block device |
pvremove | Wipes out the disk label created by pvcreate |
vgextend | Adds a physical volume to a volume group |
vgremove | Removes a physical volume from a volume group |
pvmove | Migrates data from one physical volume to another |
lvcreate | Creates a logical volume or snapshot LV |
lvextend | Grows a logical volume |
lvreduce | Shrinks a logical volume |
lvresize | Grows or shrinks a logical volume |
vgscan | Scans block devices for volume groups (necessary when using a rescue-mode boot) |
You can also enter any of these subcommands as the first argument on the lvm command line:
# lvm lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
home main -wi-ao 1.00G
multimedia main -wi-ao 512.00M
root main -wi-ao 9.77G
swap main -wi-ao 1.00G
Symbolic links have been set up from /usr/sbin/
# ls -l /usr/sbin/lvs
lrwxrwxrwx 1 root root 3 Mar 20 14:49 /usr/sbin/lvs -> lvm
# lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
home main -wi-ao 1.00G
multimedia main -wi-ao 512.00M
root main -wi-ao 9.77G
swap main -wi-ao 1.00G
The symbolic links are not available when you are in rescue mode (see Lab 10.6, "Using Rescue Mode on an Installation Disc"), so it's important to remember that you can also use these subcommands as arguments to the lvm command (for example, when in rescue mode, type lvm lvdisplay instead of lvdisplay).