| |

LFCS 86 ๐Ÿง LVM โ€” Extending Volumes

โฑ๏ธ Estimated read: 11 min | |

Extending an LVM volume is the operation that justifies the entire abstraction. A partition cannot grow while mounted; an LVM Logical Volume can. The workflow is two commands in the simple case and three when the Volume Group has no free space. The critical detail is that lvextend changes the block device’s size, not the filesystem’s, and the filesystem must be grown separatelyโ€”unless the -r flag is used, which performs both steps in one command .

This chapter covers the extension workflow: checking free space, extending the LV, growing the filesystem, and the -r shortcut. It assumes the PV and VG operations from LFCS 83 and 84, and the LV creation from LFCS 85. The focus is on the online extension that makes LVM operationally valuable: no unmount, no reboot, no maintenance window .


Key point: lvextend -r is the recommended form. The -r flag detects the filesystem type and invokes the correct resize tool automatically. Without it, the LV is larger but the filesystem still believes it has the old size.


Why extension is the core LVM operation

The online growth requirement. The LFCS Storage Management domain includes “Manage and configure LVM storage” . The operational test of that competency is whether the candidate can grow a volume while it is in use. A filesystem that must be unmounted for every resize is a filesystem that requires downtime; the LVM extension workflow is the procedure that avoids it.

The two-step separation. lvextend modifies the extent mapping. The LV gains Logical Extents, and the block device reports a larger size. The filesystem on the LV does not automatically detect the change. resize2fs for ext4 and xfs_growfs for XFS are the commands that update the filesystem’s internal metadata to use the new space . The separation exists because the filesystem is a layer above the block device, and it has no way to observe a size change without being told.

The -r shortcut. The -r flag on lvextend performs the filesystem resize as part of the same command. It detects the filesystem type from the LV’s content and calls the appropriate tool . This is the recommended practice because it removes the most common mistake: forgetting the second step and leaving the filesystem at its old size.

The VG capacity check. lvextend can only allocate extents that the VG has free. If vgs reports VFree as zero, the extension fails. The solution is to add a Physical Volume to the VG with pvcreate and vgextend, which increases the VG’s free space, and then retry the extension .


a. Checking free space before extending

The first command is vgs, which shows the VG’s total size and free space. The VFree column is the amount available for new allocations.

# Check the VG's free space.
sudo vgs

# Example output:
#   VG      #PV #LV #SN Attr   VSize   VFree
#   vg_data   2   1   0 wz--n-  19.99g  9.99g

If VFree is sufficient, the extension can proceed. If it is zero or smaller than the requested amount, the VG needs a new PV. vgdisplay provides the same information in detailed form, including the PE size and the free PE count.

# Detailed view of the VG.
sudo vgdisplay vg_data

The LV’s current size is confirmed with lvs or df -h. lvs shows the block device size; df -h shows the filesystem size. The two should match before the extension begins, and they should match again after it completes.

# Confirm the LV and filesystem sizes before extending.
sudo lvs /dev/vg_data/lv_app
df -h /mnt/app

b. Extending the LV and growing the filesystem

The lvextend command takes the LV path and a size specification. The -L option uses absolute units (G, M, T), and the -l option uses extents or percentages. The + prefix means “add this amount”; without it, the value is the target total size.

# Add 2 GB to the LV.
sudo lvextend -L +2G /dev/vg_data/lv_app

# Extend to a total of 10 GB.
sudo lvextend -L 10G /dev/vg_data/lv_app

# Use all remaining free space in the VG.
sudo lvextend -l +100%FREE /dev/vg_data/lv_app

After the LV is extended, the filesystem must be grown. The command depends on the filesystem type.

# ext4: grow online.
sudo resize2fs /dev/vg_data/lv_app

# XFS: grow online (the argument is the mount point, not the device).
sudo xfs_growfs /mnt/app

The XFS detail is a common exam trap. xfs_growfs takes the mount point, not the device path, because XFS can only be grown while mounted . resize2fs takes the device path and works on both mounted and unmounted ext4 filesystems.

The single-command form uses -r:

# Extend the LV and resize the filesystem in one step.
sudo lvextend -r -L +2G /dev/vg_data/lv_app

The -r flag is equivalent to running lvextend followed by the correct filesystem resize tool. It is the recommended form for the LFCS exam because it is simpler and less error-prone .


c. Extending when the VG has no free space

If vgs reports no free space, the VG must be extended before the LV can be. The sequence is: initialize the new disk as a PV, add it to the VG, then extend the LV and filesystem.

# Initialize the new disk as a PV.
sudo pvcreate /dev/sdd

# Add the PV to the existing VG.
sudo vgextend vg_data /dev/sdd

# Verify the new free space.
sudo vgs vg_data

# Now extend the LV and filesystem.
sudo lvextend -r -L +10G /dev/vg_data/lv_app

The new PV’s capacity becomes available in the VG immediately after vgextend. The lvextend command then allocates from the expanded pool. No unmount, no service restart, and no data migration are required .


Complete Example Session

# ============================================
# PART 1: CHECK THE CURRENT STATE
# ============================================
# Confirm the LV size and the filesystem size match.

sudo lvs /dev/vg_data/lv_app
df -h /mnt/app

# ============================================
# PART 2: CHECK VG FREE SPACE
# ============================================
# If VFree is sufficient, proceed to extend.

sudo vgs vg_data

# ============================================
# PART 3: EXTEND THE LV
# ============================================
# Add 2 GB of extents to the LV.

sudo lvextend -L +2G /dev/vg_data/lv_app

# ============================================
# PART 4: GROW THE FILESYSTEM
# ============================================
# The filesystem must be told about the new space.

# For ext4:
sudo resize2fs /dev/vg_data/lv_app

# For XFS:
# sudo xfs_growfs /mnt/app

# ============================================
# PART 5: THE ONE-STEP FORM
# ============================================
# The -r flag performs both steps.

sudo lvextend -r -L +2G /dev/vg_data/lv_app

# ============================================
# PART 6: EXTEND WITH ALL FREE SPACE
# ============================================
# Allocate the entire remaining VG capacity.

sudo lvextend -r -l +100%FREE /dev/vg_data/lv_app

# ============================================
# PART 7: THE VG IS FULL CASE
# ============================================
# If vgs shows VFree 0, add a new PV first.

sudo pvcreate /dev/sdd
sudo vgextend vg_data /dev/sdd
sudo vgs vg_data

# ============================================
# PART 8: EXTEND AFTER VG EXPANSION
# ============================================
# The new extents are now available.

sudo lvextend -r -L +10G /dev/vg_data/lv_app

# ============================================
# PART 9: VERIFY
# ============================================
# Both the LV and the filesystem must show the new size.

sudo lvs /dev/vg_data/lv_app
df -h /mnt/app

# ============================================
# PART 10: THE FULL PICTURE
# ============================================
# lvextend changes the block device.
# resize2fs / xfs_growfs changes the filesystem.
# -r combines both steps.

echo "Extension workflow complete."

The ten parts walk through the extension from the space check to the verification. The sequence is the same whether the filesystem is ext4 or XFS; only the resize command differs, and -r eliminates the difference.


Quick Reference

Extension Commands

CommandEffect
lvextend -L +2G /dev/vg/lvAdd 2 GB to the LV
lvextend -L 10G /dev/vg/lvSet total size to 10 GB
lvextend -l +100%FREE /dev/vg/lvUse all free VG space
lvextend -r -L +2G /dev/vg/lvExtend and resize filesystem

Filesystem Resize Commands

FilesystemCommandMounted?
ext4resize2fs /dev/vg/lvYes or no
XFSxfs_growfs /mountpointMust be mounted

VG Expansion Sequence

StepCommandEffect
1pvcreate /dev/sdXInitialize new PV
2vgextend vg_name /dev/sdXAdd PV to VG
3lvextend -r -L +size /dev/vg/lvExtend LV and filesystem

Verification

CheckCommandExpected
LV sizelvs /dev/vg/lvNew size
Filesystem sizedf -h /mountpointNew size
VG free spacevgs vg_nameReduced VFree

Best Practices

โœ… Do This:

# Check VG free space first.
sudo vgs vg_data                                                    // โœ…

# Use -r to extend and resize in one step.
sudo lvextend -r -L +2G /dev/vg_data/lv_app                         // โœ…

# Use xfs_growfs with the mount point for XFS.
sudo xfs_growfs /mnt/app                                            // โœ…

# Verify both LV and filesystem after extending.
sudo lvs /dev/vg_data/lv_app && df -h /mnt/app                      // โœ…

โŒ Don’t Do This:

# Don't run lvextend without the filesystem resize.
sudo lvextend -L +2G /dev/vg_data/lv_app  # filesystem unchanged    // โŒ

# Don't use xfs_growfs on an unmounted XFS filesystem.
sudo umount /mnt/app && sudo xfs_growfs /mnt/app  # fails           // โŒ

# Don't extend when VFree is 0.
sudo lvextend -L +2G /dev/vg_data/lv_app  # fails: no space         // โŒ

Common Pitfalls

PitfallWhy It HappensFix
LV larger, filesystem unchangedForgot the resize stepRun resize2fs / xfs_growfs, or use -r
lvextend failsVG has no free extentspvcreate + vgextend first
xfs_growfs failsFilesystem not mountedMount, then run xfs_growfs /mountpoint
Extension succeeds but app sees old sizeApp cached the sizeRestart the app or re-check with df

Real-World Examples

1. Check Free Space

sudo vgs

2. Extend by Amount

sudo lvextend -L +5G /dev/vg_data/lv_app

3. Extend to Total

sudo lvextend -L 20G /dev/vg_data/lv_app

4. Use All Free

sudo lvextend -l +100%FREE /dev/vg_data/lv_app

5. Grow ext4

sudo resize2fs /dev/vg_data/lv_app

6. Grow XFS

sudo xfs_growfs /mnt/app

7. One-Step Extend

sudo lvextend -r -L +2G /dev/vg_data/lv_app

8. Add PV to VG

sudo pvcreate /dev/sdd && sudo vgextend vg_data /dev/sdd

9. Extend After VG Growth

sudo lvextend -r -L +10G /dev/vg_data/lv_app

10. Verify Both

sudo lvs /dev/vg_data/lv_app && df -h /mnt/app

Visual

The Extension Workflow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  1. vgs โ†’ check VFree                                   โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”                                          โ”‚
โ”‚    โ–ผ         โ–ผ                                          โ”‚
โ”‚  SUFFICIENT  ZERO                                       โ”‚
โ”‚    โ”‚         โ”‚                                          โ”‚
โ”‚    โ”‚         โ–ผ                                          โ”‚
โ”‚    โ”‚    pvcreate /dev/sdX                               โ”‚
โ”‚    โ”‚    vgextend vg /dev/sdX                            โ”‚
โ”‚    โ”‚         โ”‚                                          โ”‚
โ”‚    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜                                          โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  2. lvextend -r -L +size /dev/vg/lv                     โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  3. lvs + df -h โ†’ verify                                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The Two-Step vs One-Step

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  TWO-STEP                                               โ”‚
โ”‚  lvextend -L +2G /dev/vg/lv                             โ”‚
โ”‚  resize2fs /dev/vg/lv                                   โ”‚
โ”‚                                                         โ”‚
โ”‚  ONE-STEP                                               โ”‚
โ”‚  lvextend -r -L +2G /dev/vg/lv                          โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ  detects filesystem, calls resize tool        โ”‚
โ”‚  (ext4 โ†’ resize2fs, XFS โ†’ xfs_growfs)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The XFS Detail

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ext4: resize2fs /dev/vg/lv                             โ”‚
โ”‚  โ†’ device path                                          โ”‚
โ”‚  โ†’ works mounted or unmounted                           โ”‚
โ”‚                                                         โ”‚
โ”‚  XFS: xfs_growfs /mountpoint                            โ”‚
โ”‚  โ†’ mount point, not device path                         โ”‚
โ”‚  โ†’ must be mounted                                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The VG Full Case

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  vgs โ†’ VFree 0                                          โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  pvcreate /dev/sdd                                      โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ                                               โ”‚
โ”‚  vgextend vg_data /dev/sdd                              โ”‚
โ”‚         โ”‚                                               โ”‚
โ”‚         โ–ผ  VFree increases                              โ”‚
โ”‚  lvextend -r -L +10G /dev/vg_data/lv_app                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
Check free spacevgs (VFree column)
Extend LVlvextend -L +size /dev/vg/lv
Resize ext4resize2fs /dev/vg/lv
Resize XFSxfs_growfs /mountpoint
One-steplvextend -r -L +size /dev/vg/lv
VG fullpvcreate + vgextend first
Verifylvs and df -h

Key takeaways:

  • lvextend changes the block device, not the filesystem. The filesystem must be resized separately with resize2fs or xfs_growfs, unless the -r flag is used .
  • lvextend -r is the recommended form. It detects the filesystem type and invokes the correct resize tool, eliminating the most common mistake .
  • XFS uses the mount point, not the device path. xfs_growfs /mnt/app is the correct form; the filesystem must be mounted .
  • If the VG is full, add a PV first. pvcreate initializes the disk, vgextend adds it to the VG, and then lvextend can allocate from the expanded pool .
  • Verify both layers after extending. lvs shows the LV size, df -h shows the filesystem size, and the two should match.
  • Extension is online. The LV and filesystem can be grown while the application is running and writing data. This is the operational advantage that justifies LVM .

Remember: Extending an LVM volume is two operations that look like one. The LV is a block device; the filesystem is a layer above it. lvextend changes the block device, and the resize command changes the filesystem. The -r flag combines them, and the combination is the correct practice. When the VG has no free space, the sequence starts one layer lower: pvcreate, vgextend, then lvextend -r. The commands are simple; the discipline is checking the VG first and verifying both layers after.


Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!