Commands by layer
| Layer | Create | Show | Extend |
|---|---|---|---|
| PV | pvcreate /dev/sdb |
pvs |
— |
| VG | vgcreate data /dev/sdb |
vgs |
vgextend data /dev/sdc |
| LV | lvcreate -L 10G -n vol1 data |
lvs |
lvextend -r -L +5G ... |
LVM: physical volumes, volume groups and logical volumes (PV → VG → LV), extending and snapshots.
lsblk
block device tree
pvs
physical volumes
vgs
volume groups
lvs
logical volumes
sudo lvextend -r -l +100%FREE /dev/vg/lv
extend the LV+fs onto all free space
sudo vgextend vg /dev/sdc
add a disk to the group
sudo lvcreate -L 2G -s -n snap /dev/vg/lv
a snapshot
sudo lvconvert --merge /dev/vg/snap
roll back to the snapshot
LVM adds a layer of abstraction over disks: volumes can be extended, moved and snapshotted without repartitioning.
Status of the whole stack: pvs, vgs, lvs (or the detailed
pvdisplay/vgdisplay/lvdisplay).
| Layer | Create | Show | Extend |
|---|---|---|---|
| PV | pvcreate /dev/sdb |
pvs |
— |
| VG | vgcreate data /dev/sdb |
vgs |
vgextend data /dev/sdc |
| LV | lvcreate -L 10G -n vol1 data |
lvs |
lvextend -r -L +5G ... |
The LV isn't the filesystem. After lvextend, grow the filesystem
itself: resize2fs (ext4) or xfs_growfs (xfs). Or use lvextend -r
directly.
The group is full — add a PV: pvcreate /dev/sdc + vgextend data /dev/sdc.
A snapshot stores changes; if the original volume is written to heavily and
the snapshot is too small, it overflows (lvs shows 100%). Size snapshots
generously and take the copy quickly.
sudo vgchange -ay (activate it), and check auto-activation and
/etc/fstab (mount by /dev/<vg>/<lv> or UUID).
Data is gone. Before lvremove/lvreduce, always double-check against
lvs and make a snapshot/backup.
Danger.
lvremovedeletes a logical volume and its data with no way to undo it;vgremove/pvremovedestroy the group's and physical volume's metadata entirely. Cross-check againstlvs/vgsand confirm a backup exists before deleting — verify by UUID or mount point, not just by name.Running
mkfson top of an existing LV wipes its filesystem and data just as irreversibly as on a regular partition.lvconvert --mergeto roll back to a snapshot irreversibly loses every change made after the snapshot was taken.
Found an inaccuracy? Report an error in the article