How to Expand LVM Partitions: Complete Step-by-Step Guide
Logical Volume Manager (LVM) is one of the most powerful storage management tools in Linux, providing unprecedented flexibility for disk space management. Unlike traditional partitioning, LVM allows you to dynamically resize storage volumes without downtime, making it essential for modern Linux server administration.
This comprehensive guide walks you through expanding LVM partitions, from basic concepts to advanced scenarios, ensuring you can confidently manage storage growth on production systems.
Introduction to LVM
LVM creates an abstraction layer between physical storage devices and the filesystems, enabling flexible storage management that traditional partitioning cannot provide. Understanding LVM's architecture is crucial before attempting to expand volumes.
LVM Architecture Components
LVM consists of three main layers:
- Physical Volumes (PV): Physical disks or partitions (/dev/sda1, /dev/sdb, etc.)
- Volume Groups (VG): Pools of physical volumes grouped together
- Logical Volumes (LV): Virtual partitions carved from volume groups
This layered approach allows you to:
- Expand volumes across multiple disks
- Resize volumes dynamically
- Create snapshots for backups
- Migrate data between disks
- Add storage capacity without downtime
When to Use LVM
LVM is ideal for:
- Production servers requiring flexible storage
- Database servers with growing data
- Virtual machine hosts
- Systems requiring snapshots
- Multi-disk storage configurations
- Environments requiring online resizing
Prerequisites
Before expanding LVM partitions, ensure you have:
- Root or sudo access to your Linux system
- Basic understanding of LVM concepts
- Knowledge of current LVM configuration
- Complete backup of all critical data
- Sufficient free space (either in VG or new physical disks)
- Understanding of your filesystem type (ext4, XFS, etc.)
Critical Safety Warning
WARNING: While LVM operations are generally safe, expanding filesystems can lead to data loss if done incorrectly. Always:
- Create complete backups before proceeding
- Verify free space availability
- Test procedures in non-production environments
- Document current configuration
- Have a rollback plan
- Understand filesystem-specific resize requirements
Understanding Current LVM Configuration
Before expanding, thoroughly understand your current setup.
View Physical Volumes
sudo pvdisplay
Or for summary:
sudo pvs
Output example:
PV VG Fmt Attr PSize PFree
/dev/sda3 ubuntu-vg lvm2 a-- <99.00g 0
View Volume Groups
sudo vgdisplay
Or for summary:
sudo vgs
Output example:
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 2 0 wz--n- <99.00g 0
View Logical Volumes
sudo lvdisplay
Or for summary:
sudo lvs
Output example:
LV VG Attr LSize Pool Origin Data% Meta%
root ubuntu-vg -wi-ao---- <89.00g
swap_1 ubuntu-vg -wi-ao---- 10.00g
Complete System Overview
sudo pvs && sudo vgs && sudo lvs
View Disk and Partition Layout
lsblk
Output example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda3 8:3 0 99G 0 part
├─ubuntu--vg-root 253:0 0 89G 0 lvm /
└─ubuntu--vg-swap_1 253:1 0 10G 0 lvm [SWAP]
sdb 8:16 0 500G 0 disk
Check Filesystem Type
df -T
Output:
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root ext4 89G 75G 10G 89% /
Scenario 1: Expanding LVM with Existing Free Space in Volume Group
This is the simplest scenario where your volume group has unallocated space.
Step 1: Check Available Space in Volume Group
sudo vgs
Look for available space in the VFree column:
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 2 0 wz--n- <99.00g 20.00g
In this example, 20GB is available for expansion.
Step 2: Extend Logical Volume
Extend by specific size:
sudo lvextend -L +20G /dev/ubuntu-vg/root
Or extend to use all available space:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
Output:
Size of logical volume ubuntu-vg/root changed from 89.00 GiB to 109.00 GiB.
Logical volume ubuntu-vg/root successfully resized.
Step 3: Resize Filesystem
The logical volume is now larger, but the filesystem must be resized to use the new space.
For ext4 Filesystem (can be done online)
sudo resize2fs /dev/ubuntu-vg/root
Output:
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/ubuntu-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 12, new_desc_blocks = 14
The filesystem on /dev/ubuntu-vg/root is now 28573696 (4k) blocks long.
For XFS Filesystem (must be mounted)
sudo xfs_growfs /
Note: XFS uses the mount point, not the device path.
For ext3 Filesystem
sudo resize2fs /dev/ubuntu-vg/root
Step 4: Verify Expansion
df -h
Output:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root 109G 75G 30G 72% /
Complete Command Sequence for Quick Reference
# Check available space
sudo vgs
# Extend logical volume (use all free space)
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
# Resize filesystem (ext4)
sudo resize2fs /dev/ubuntu-vg/root
# Verify
df -h
Scenario 2: Expanding LVM by Adding a New Physical Disk
When your volume group has no free space, add a new physical disk.
Step 1: Identify New Disk
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda3 8:3 0 99G 0 part
├─ubuntu--vg-root 253:0 0 89G 0 lvm /
└─ubuntu--vg-swap_1 253:1 0 10G 0 lvm [SWAP]
sdb 8:16 0 500G 0 disk
New disk is /dev/sdb (500GB, no partitions).
Step 2: Create Physical Volume
Create PV on entire disk:
sudo pvcreate /dev/sdb
Output:
Physical volume "/dev/sdb" successfully created.
Or create PV on a partition (if partitioned):
# First partition the disk
sudo parted /dev/sdb mklabel gpt
sudo parted /dev/sdb mkpart primary 0% 100%
sudo parted /dev/sdb set 1 lvm on
# Then create PV
sudo pvcreate /dev/sdb1
Step 3: Extend Volume Group
Add the new PV to your existing VG:
sudo vgextend ubuntu-vg /dev/sdb
Output:
Volume group "ubuntu-vg" successfully extended
Step 4: Verify Volume Group Expansion
sudo vgs
Output:
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 2 2 0 wz--n- <599.00g <500.00g
Notice VSize increased and VFree shows available space.
Step 5: Extend Logical Volume
# Extend by specific size
sudo lvextend -L +200G /dev/ubuntu-vg/root
# Or use all available space
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
Step 6: Resize Filesystem
For ext4:
sudo resize2fs /dev/ubuntu-vg/root
For XFS:
sudo xfs_growfs /
Step 7: Verify Complete Configuration
# Check physical volumes
sudo pvs
# Check volume groups
sudo vgs
# Check logical volumes
sudo lvs
# Check filesystem
df -h
Complete Command Sequence for Adding New Disk
# Identify new disk
lsblk
# Create physical volume
sudo pvcreate /dev/sdb
# Extend volume group
sudo vgextend ubuntu-vg /dev/sdb
# Extend logical volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
# Resize filesystem (ext4)
sudo resize2fs /dev/ubuntu-vg/root
# Verify
df -h
Scenario 3: Expanding LVM by Extending Existing Physical Volume
When using cloud VPS or virtual machines, you can often expand existing disks without adding new ones.
Step 1: Expand Physical Disk
This step depends on your environment:
For VMware/VirtualBox:
- Use hypervisor tools to expand disk
For Cloud Providers (AWS, Azure, Google Cloud):
- Use cloud console to resize disk volume
For physical servers:
- Not applicable; add new disk instead
After expanding in hypervisor/cloud, the OS needs to recognize the new size.
Step 2: Rescan Disk for New Size
# Rescan SCSI devices
echo 1 | sudo tee /sys/class/block/sda/device/rescan
# Verify new size
sudo fdisk -l /dev/sda
Or for all disks:
for disk in /sys/class/scsi_device/*/device/rescan; do
echo 1 | sudo tee $disk
done
Step 3: Expand Partition (if LVM is on partition)
If your LVM physical volume is on a partition (e.g., /dev/sda3), resize the partition.
Using parted:
sudo parted /dev/sda
Inside parted:
(parted) print
Number Start End Size File system Name Flags
1 1049kB 1075MB 1074MB ext4 primary boot
3 1075MB 107GB 106GB primary lvm
(parted) resizepart 3 100%
(parted) quit
Using growpart (easier):
sudo growpart /dev/sda 3
Step 4: Resize Physical Volume
sudo pvresize /dev/sda3
Output:
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
Step 5: Verify PV Resize
sudo pvs
Output:
PV VG Fmt Attr PSize PFree
/dev/sda3 ubuntu-vg lvm2 a-- <200.00g <101.00g
Notice PSize and PFree increased.
Step 6: Extend Logical Volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
Step 7: Resize Filesystem
For ext4:
sudo resize2fs /dev/ubuntu-vg/root
For XFS:
sudo xfs_growfs /
Step 8: Verify
df -h
Complete Command Sequence for Extending Existing Disk
# After expanding disk in hypervisor/cloud
# Rescan disk
echo 1 | sudo tee /sys/class/block/sda/device/rescan
# Expand partition
sudo growpart /dev/sda 3
# Resize physical volume
sudo pvresize /dev/sda3
# Extend logical volume
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
# Resize filesystem (ext4)
sudo resize2fs /dev/ubuntu-vg/root
# Verify
df -h
Scenario 4: Expanding Specific Logical Volume in Multi-LV Setup
Systems often have multiple logical volumes. Expand specific volumes carefully.
View All Logical Volumes
sudo lvs
Output:
LV VG Attr LSize Pool Origin Data%
home ubuntu-vg -wi-ao---- <50.00g
root ubuntu-vg -wi-ao---- <89.00g
var ubuntu-vg -wi-ao---- <30.00g
Extend Specific Logical Volume
Extend /home by 20GB:
sudo lvextend -L +20G /dev/ubuntu-vg/home
Extend /var using all remaining free space:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/var
Extend /home by 50% of free space:
sudo lvextend -l +50%FREE /dev/ubuntu-vg/home
Resize Corresponding Filesystem
# For ext4 on /home
sudo resize2fs /dev/ubuntu-vg/home
# For XFS on /var (use mount point)
sudo xfs_growfs /var
Advanced LVM Expansion Techniques
Using lvextend with Automatic Filesystem Resize
Modern LVM versions support automatic filesystem resizing:
# For ext4 and XFS
sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/root
The -r flag automatically resizes the filesystem.
Extending Multiple Logical Volumes
# Extend multiple LVs proportionally
sudo lvextend -L +10G /dev/ubuntu-vg/root
sudo lvextend -L +20G /dev/ubuntu-vg/home
sudo lvextend -L +10G /dev/ubuntu-vg/var
# Resize filesystems
sudo resize2fs /dev/ubuntu-vg/root
sudo resize2fs /dev/ubuntu-vg/home
sudo resize2fs /dev/ubuntu-vg/var
Creating New Logical Volume from Free Space
Instead of extending, create new LV:
# Create new logical volume
sudo lvcreate -L 100G -n data ubuntu-vg
# Create filesystem
sudo mkfs.ext4 /dev/ubuntu-vg/data
# Mount
sudo mkdir /mnt/data
sudo mount /dev/ubuntu-vg/data /mnt/data
# Add to fstab
echo "/dev/ubuntu-vg/data /mnt/data ext4 defaults 0 2" | sudo tee -a /etc/fstab
Migrating Data Between Physical Volumes
Move data from one PV to another:
# Move extents from /dev/sda3 to /dev/sdb
sudo pvmove /dev/sda3 /dev/sdb
Useful when replacing old disks.
Verification and Testing
Comprehensive System Check
# Physical volumes
sudo pvdisplay
# Volume groups
sudo vgdisplay
# Logical volumes
sudo lvdisplay
# Filesystem usage
df -h
# Complete overview
sudo lsblk -f
Verify Filesystem Integrity
For ext4:
# Check filesystem (requires unmount for full check)
sudo umount /dev/ubuntu-vg/home
sudo e2fsck -f /dev/ubuntu-vg/home
sudo mount /dev/ubuntu-vg/home /home
For XFS (while mounted):
sudo xfs_repair -n /dev/ubuntu-vg/data
Test Write Performance
# Create test file
sudo dd if=/dev/zero of=/test_file bs=1G count=1 oflag=direct
# Remove test file
sudo rm /test_file
Troubleshooting Common Issues
Issue: "Insufficient free space" When Extending
Cause: Volume group has no available space.
Solution:
Check VG free space:
sudo vgs
If VFree is 0, add new physical volume:
sudo pvcreate /dev/sdc
sudo vgextend ubuntu-vg /dev/sdc
Issue: Filesystem Not Using New Space After lvextend
Cause: Forgot to resize filesystem.
Solution:
Resize filesystem:
# For ext4
sudo resize2fs /dev/ubuntu-vg/root
# For XFS
sudo xfs_growfs /
Issue: "Device or resource busy" During pvresize
Cause: Logical volumes are actively using the PV.
Solution:
This is usually safe; pvresize works online. If issues persist:
# Check what's using the device
sudo lsof | grep sda3
# Ensure LVs are active
sudo lvchange -ay /dev/ubuntu-vg/root
Issue: Partition Not Resized After Disk Expansion
Cause: Kernel hasn't re-read partition table.
Solution:
# Force partition table re-read
sudo partprobe /dev/sda
# Or use blockdev
sudo blockdev --rereadpt /dev/sda
# If above fails, reboot
sudo reboot
Issue: pvresize Shows No Space Increase
Cause: Partition wasn't resized before pvresize.
Solution:
# Check partition size
sudo fdisk -l /dev/sda
# Resize partition first
sudo growpart /dev/sda 3
# Then resize PV
sudo pvresize /dev/sda3
Issue: Cannot Extend LV Across Multiple PVs
Cause: Default LVM allocation policy.
Solution:
Allow extending across PVs:
sudo lvextend -L +50G --alloc anywhere /dev/ubuntu-vg/root
Issue: XFS Filesystem Won't Grow
Cause: Wrong command or partition not mounted.
Solution:
XFS must be mounted and uses mount point:
# Check if mounted
mount | grep ubuntu--vg-root
# Use mount point, not device
sudo xfs_growfs /
# NOT: sudo xfs_growfs /dev/ubuntu-vg/root
Best Practices for LVM Expansion
1. Always Backup Before Expansion
Create backups before any LVM operations:
# LVM snapshot (quick, space-efficient)
sudo lvcreate -L 10G -s -n root_snapshot /dev/ubuntu-vg/root
# Traditional backup
sudo rsync -avxHAX / /backup/root/
2. Leave Free Space in Volume Groups
Don't allocate 100% of VG space:
# Leave 10-20% free for:
# - Snapshots
# - Future flexibility
# - Emergency space
sudo lvextend -l +80%FREE /dev/ubuntu-vg/root
3. Monitor Disk Usage Proactively
Set up monitoring before running out of space:
# Create monitoring script
cat << 'EOF' | sudo tee /usr/local/bin/check_disk_space.sh
#!/bin/bash
THRESHOLD=80
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "WARNING: Root filesystem at ${USAGE}% capacity"
# Send alert
fi
EOF
sudo chmod +x /usr/local/bin/check_disk_space.sh
# Add to cron
echo "0 * * * * /usr/local/bin/check_disk_space.sh" | sudo crontab -
4. Document LVM Configuration
Maintain documentation:
# Save configuration
sudo vgcfgbackup ubuntu-vg
# Export configuration
sudo pvs > /root/lvm_config_$(date +%Y%m%d).txt
sudo vgs >> /root/lvm_config_$(date +%Y%m%d).txt
sudo lvs >> /root/lvm_config_$(date +%Y%m%d).txt
5. Use Consistent Naming
Follow naming conventions:
# Good examples:
/dev/vg_data/lv_mysql
/dev/vg_web/lv_html
/dev/vg_backup/lv_archives
# Avoid:
/dev/volume1/thing
/dev/vg/data
6. Plan Growth Strategy
Implement planned growth:
# Incremental growth
sudo lvextend -L +20G /dev/ubuntu-vg/root # Not 100%FREE
# Allows for:
# - Multiple smaller expansions
# - Monitoring between expansions
# - Easier troubleshooting
7. Test in Non-Production First
Always test procedures:
# Create test environment
# Practice expansion procedures
# Document steps
# Then apply to production
8. Use UUID in fstab
Ensure reliability across reboots:
# Find UUID
sudo blkid /dev/ubuntu-vg/home
# Use in /etc/fstab
UUID=xxx-xxx-xxx /home ext4 defaults 0 2
# Not:
/dev/ubuntu-vg/home /home ext4 defaults 0 2
Advanced LVM Scenarios
Creating Striped Logical Volumes
Distribute data across multiple PVs for performance:
# Create striped LV across 2 PVs
sudo lvcreate -L 100G -i 2 -I 64 -n striped_data ubuntu-vg /dev/sdb /dev/sdc
Options:
- -i 2: Stripe across 2 devices
- -I 64: 64KB stripe size
Setting Up LVM Thin Provisioning
Over-commit storage space:
# Create thin pool
sudo lvcreate -L 500G -T ubuntu-vg/thin_pool
# Create thin volume
sudo lvcreate -V 100G -T ubuntu-vg/thin_pool -n thin_vol1
Automating LVM Expansion
Create expansion script:
cat << 'EOF' | sudo tee /usr/local/bin/auto_expand_lvm.sh
#!/bin/bash
VG="ubuntu-vg"
LV="root"
THRESHOLD=90
USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
FREE=$(vgs --noheadings -o vg_free --units g $VG | sed 's/g//' | awk '{print int($1)}')
if [ "$FREE" -gt 10 ]; then
lvextend -L +10G /dev/$VG/$LV
resize2fs /dev/$VG/$LV
echo "Extended $LV by 10GB"
fi
fi
EOF
sudo chmod +x /usr/local/bin/auto_expand_lvm.sh
LVM Expansion Cheat Sheet
Quick Reference Commands
# Check current configuration
sudo pvs && sudo vgs && sudo lvs
# Add new disk
sudo pvcreate /dev/sdb
sudo vgextend ubuntu-vg /dev/sdb
# Extend LV (use all free space)
sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
# Extend LV (specific size)
sudo lvextend -L +50G /dev/ubuntu-vg/root
# Resize ext4 filesystem
sudo resize2fs /dev/ubuntu-vg/root
# Resize XFS filesystem
sudo xfs_growfs /
# Extend with auto-resize
sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/root
# Check results
df -h
Expansion Decision Tree
Need more space?
├─ Free space in VG?
│ ├─ Yes → lvextend → resize filesystem
│ └─ No → Can add new disk?
│ ├─ Yes → pvcreate → vgextend → lvextend → resize filesystem
│ └─ No → Can expand existing disk?
│ ├─ Yes → rescan → growpart → pvresize → lvextend → resize
│ └─ No → Consider removing data or adding external storage
Conclusion
Expanding LVM partitions is a fundamental Linux administration skill that enables flexible storage management without downtime. By understanding the three main expansion scenarios—using existing free space, adding new disks, or expanding existing disks—you can confidently handle storage growth in production environments.
Key takeaways:
- Always backup before LVM operations
- Understand your current configuration before expanding
- Choose the right scenario for your situation
- Extend LV first, then resize filesystem
- Use
-rflag for automatic filesystem resize - Verify at each step to catch issues early
- Document your LVM layout for future reference
- Leave free space in volume groups for flexibility
- Test procedures in non-production environments
- Monitor proactively to avoid emergency expansions
LVM's flexibility makes it the preferred choice for storage management on Linux servers. By following the procedures and best practices outlined in this guide, you can ensure reliable, safe storage expansion that meets your infrastructure's growing needs.
Remember that proper LVM management isn't just about expanding when needed—it's about proactive monitoring, strategic planning, and implementing best practices that prevent storage emergencies and ensure long-term system reliability.


