Skip to main content
In this hands-on walkthrough you’ll create and manage Logical Volumes (LVM). We’ll:
  • initialize block device partitions as Physical Volumes (PVs)
  • create and extend a Volume Group (VG)
  • create, format, mount, and extend a Logical Volume (LV)
  • move data off a failing PV
  • grow the filesystem to use added space
  • make the mount persistent and clean up when finished
A dark-themed slide titled "Demo — Working with Logical Volumes" showing a vertical list of steps: Create an LV, Format, Mount, Extend, and Verify the change. The layout features the heading on the left and rounded rectangular buttons on the right.
By the end you’ll not only know what logical volumes are, but how to manage them on a running Linux system. Callout: prerequisites and quick tips
This demo assumes root privileges. LVM commands (pvcreate, vgcreate, lvcreate, etc.) require administrative access. If you run into “device busy” errors, ensure the device is not mounted or in use.
Quick LVM reference Inspect block devices Start by listing block devices to identify the partitions on /dev/sdb:
Initialize partitions as Physical Volumes (PVs) Use pvcreate to prepare partitions for LVM:
Verify created PVs with pvdisplay (or pvscan / pvs):
Create and inspect a Volume Group (VG) Create a VG named vg1 using one PV (we’ll add more shortly):
Inspect the VG:
Extend the VG by adding another PV:
To remove a PV from a VG (for maintenance or replacement) use vgreduce. Example:
You can re-add PVs as needed:
Create a Logical Volume (LV) Create an LV named lv1 of 400 MiB in vg1:
Confirm the LV:
Format and mount the LV Create a mount point and format the LV with XFS:
Mount the LV and verify with lsblk:
Check space usage for the mount:
Extend the Logical Volume You can extend an LV to an absolute size or by specifying an increment. To resize lv1 from 400 MiB to 800 MiB:
Important: growing the LV updates the block device size, but the filesystem on top of that LV must also be grown before the OS can use the additional space. Move data off a failing PV (pvmove) If a PV is failing or needs to be removed from service, relocate its data with pvmove:
After pvmove, verify the LV no longer uses the old PV:
Grow the filesystem to use the new space Check df to confirm the filesystem still reports the old size:
For XFS filesystems, use xfs_growfs and specify the mount point (XFS is grown online while mounted):
Verify the filesystem reflects the larger size:
Callout: filesystem compatibility note
xfs_growfs only works on XFS filesystems. For ext3/ext4 use resize2fs. XFS filesystems can be grown but not shrunk; ext3/ext4 can usually be grown and sometimes reduced.
Make the LV mount persistent Get the LV device UUID with blkid and add an /etc/fstab entry to ensure the mount survives reboots:
Example /etc/fstab fragment (use the UUID you obtained):
To test the fstab entry:
  1. Unmount the filesystem
  2. If systemd caches fstab, reload the daemon
  3. Run mount -a to mount all filesystems from fstab
Cleanup when finished When you’re done with the demo, unmount and remove the LV, VG, and PV labels to restore devices to their pre-LVM state:
Summary This demo covered the full lifecycle of LVM on a system:
  • prepare partitions as PVs with pvcreate
  • create and manage VGs with vgcreate, vgextend, and vgreduce
  • create and resize LVs with lvcreate and lvextend
  • relocate data away from failing PVs with pvmove
  • format and mount LVs, then grow filesystems (xfs_growfs for XFS)
  • persist mounts via /etc/fstab
  • and cleanup (remove LV, VG, PV labels)
Links and references

Watch Video