What is LVM in Linux? Easily Manage Disks with Logical Volume Manager

Logical Volume Manager (LVM) in Linux showing disk management with physical volumes, volume groups, and logical volumes

Introduction to LVM in Linux
The ability to manage disk storage is one of the significant skills to learn as a Linux user or system administrator. Considerable limitations arise from traditional disk partitioning methods particularly when flexibility, scalability and storage efficiency are required. This is where LVM (Logical Volume Manager) comes into play.

dynamic and flexible storage solutions. LVM allows one to resize, extend, and manage storage volumes without any problem even when one is using the system rather than relying on the fixed disk partitions.

LVM is a powerful disk management tool that can make disk management simple whether you are interacting with a personal Linux system or enterprise servers.

Before working with Logical Volume Manager (LVM) in Linux, it is important to understand how disks and storage commands work. If you are new, read our complete guide on Best Disk & Storage Commands in Linux.

What is LVM in Linux?

LVM (Logical Volume Manager) is a storage management utility which transforms the physical storage into logical units. They are used to aggregate a number of physical disks into one storage pool, and to dynamically allocate space as it is needed.

Simple Definition

LVM is a method of disk management that allows a flexible resizing of disks, combines storage and creates logical partitions.


Traditional Partitioning vs LVM
Feature Traditional Partitioning LVM
Flexibility Limited Highly flexible
Resize partitions Difficult Easy
Combine disks Not possible Yes
Snapshots No Yes
Downtime required Often Rarely


Key Insight

Traditional partitions are not flexible while LVM provides flexibility and scalability.


Key Features of LVM

LVM has a number of compelling qualities that are best suited to modern Linux systems.
  •   Flexible Disk Management
  •   Dynamic Resizing
  •   Storage Pooling
  •   Snapshots
  •   Data Migration

LVM Architecture Explained
LVM architecture in Linux is built in three layers which are Physical Volumes (PVs), Volume Groups (VGs), and Logical Volumes (LVs).LVM architecture in Linux showing physical volumes, volume groups, and logical volumes for flexible disk management

Physical Volume (PV)
A Physical Volume can be a disk or partition initialized for LVM.

Example:
/dev/sdb
/dev/sd
Linux LVM physical volume (PV) creation and details shown using pvcreate and pvdisplay commands

2 disks created with a capacity of 10 GB for this guide. You can create even partitions instead of physical or virtual disks.

To effectively manage disks using LVM, you should first know how to check system and hardware information. Learn more in our guide on 8 Best Commands to Check System Information in Linux.

Volume Group (VG)
A Volume Group is a pool of storage created by combining multiple PVs. Consider VG as a storage container.

Logical Volume (LV)
A Logical Volume is a virtual partition created from a VG. This is what you mount and work with.

LVM Flow
Physical Disk PV VG LV File system Mount PointLVM flow in Linux showing physical volumes converted into volume groups and logical volumes for flexible disk management

How LVM Works (Step-by-Step)
  1. Convert disk into Physical Volume
  2. Combine PVs into Volume Group
  3. Create Logical Volume from VG
  4. Format and mount the LV 
This layered approach gives LVM its flexibility.

Advantages of LVM in Linux

·       Easy Resizing
·       Better Storage Utilization
·       Snapshots for short-term Backup or recovery
·       Scalability
·       High Flexibility

Disadvantages of LVM

1. Complexity
It can be a bit challenging to beginners.

2. Recovery Challenges
Data recovery is more complex as compared to standard partitions.

3. Slight Overhead
Minimal performance impact.

LVM Commands in Linux (Step-by-Step Guide)

Step 1: Install LVM
Before the installation of lvm check it is already installed on the system, for this run the following command.

#sudo lvm versionLinux LVM version output using sudo lvm version command in terminal

In case lvm is not installed on the system then first thing to do is install lvm on the system or if previous version of lvm is installed update it with latest one.

If you are a beginner, understanding basic Linux commands will help you follow LVM operations easily. Read our beginners friendly guide on Basic Linux Commands Guide.


For Installation or Update
Run this command to update the overall system

#sudo apt updateRunning sudo apt update command in Linux terminal to update package lists

After successfully updating the system, now install lvm utility with this command.

#sudo apt install lvm2 -yInstalling LVM2 package in Linux using sudo apt install lvm2 -y command in terminal

To update the older version of lvm with latest version command is

#sudo apt --only-upgrade lvm2 -y

Step 2: Create Physical Volume
Lvm latest version is installed on the system, now create physical volume using the following command.

#sudo pvcreate /dev/sdb /dev/sdcInstalling LVM2 package in Linux using sudo apt install lvm2 -y command in terminal

Check PV:
To check physical volume is create, command is

#sudo pvdisplayScreenshot showing output of pvdisplay command displaying Linux LVM physical volume information

Step 3: Create Volume Group
Now create volume group with the following command

#sudo  vgcreate  my_vg  /dev/sdb  /dev/sdcScreenshot showing vgcreate command used to create a volume group in Linux LVM

Check VG:
Now check volume group is created

#sudo vgdisplayScreenshot showing vgdisplay command output displaying Linux LVM volume group information

Step 4: Create Logical Volume
This command is used to create logical volume. Volume size is adjustable as required. All space can be allocated to single logical volume but it depends on the usage scenario. Here logical volume of 5G will be created.

#sudo lvcreate -L 5G -n my_lv my_vgScreenshot showing lvcreate command used to create a logical volume in Linux LVM

Command Explanation:

sudo
·       Run the command with superuser (root) privileges
·       It is required because disk operations need admin access

lvcreate
·       The lvcreate command is used to create a logical volume
·       Dynamic partitions within the volume groups are logical volumes

-L 5G
·       Size of the logical volume
·       5G means Gigabytes, you can use M (MB), T (TB) etc.

-n my_lv
·       Sets the name of the logical volume
·       In this case the new volume name is called my_lv

my_vg
·       This is the volume group name
·       The logical volume is created in this volume group
·       A volume group is made of one or more physical disks or partitions

Summary
This command creates a logical volume with the name of my_lv inside the volume group my_vg using root privileges.

Step 5: Format Logical Volume
Now format the logical volume using this command

#sudo mkfs.ext4 /dev/my_ vg/my_lvScreenshot showing mkfs.ext4 command used to format a partition with ext4 filesystem in Linux

Command explanation:

Mkfs.ext4
·       Stands for make file system (ext4)
·       It creates ext4 file system on the specified device

ext4
·       One of the most popular Linux file system
·       Reliable and fast
·       Supports large files and journaling

/dev/my_vg/my_lv
·       This is the logical volume path
·       Created earlier using lvcreate
·       Acts like a virtual disk or partition

Note: This command will destroy any existing data on /dev/my_vg/my_lv.

Step 6: Mount Logical Volume
Create directory named mydata inside /mnt and mount the previously created logical volume on this mount point.

#sudo mkdir /mnt/mydata
#sudo mount /dev/my_vg/my_lv   /mnt/mydataScreenshot showing mkdir /mnt/mydata command used to create a mount directory in Linux

Verify the Mount

#sudo df -h

Command explanation:

Mount
·       Mount is a Linux command used to attach a file system to directory

/dev/my_vg/my_lv
·       This is logical volume created earlier using LVM
·       It contains the file system ext4 in this case

/mnt/mydata
·       The mount point (target directory)
·       This is where file system will be accessed

Verify the mount
·       Displays mounted file system and their usage
·       Confirms that logical volume is successfully mounted

Summary
·       The system links the logical volume to /mnt/mydata
·       Files stored in this logical volume accessed through this directory
·       It is a directory that serves as an entry point into the volume


After setting up LVM, monitoring the system performance becomes important. You can learn how to track system resources in our guide on Linux System Performance with top and htop.


How to Add LVM Mount Entry in /etc/fstab
To make LVM logical volume mount automatically at boot you need to add an entry in the /etc/fstab file.

1. Get UUID of the Logical Volume
It is recommended to use UUID instead of device path for reliability.

#sudo blkid /dev/my_vg/my_lvcreenshot showing blkid command output displaying block device UUID and filesystem type in Linux

2. Edit /etc/fstab

#sudo vim /etc/fstabScreenshot showing sudo vim /etc/fstab command used to edit filesystem mount configuration in Linux

3. Add Entry

Add the following line at the end of the file.Screenshot showing entry added in /etc/fstab file to configure automatic filesystem mounting in Linux

4.  Test the Configuration
Before rebooting test the entry.

#sudo mount -aScreenshot showing mount -a command used to mount all filesystems defined in /etc/fstab in Linux

·       If no errors then configuration is correct
·       If error then fix before reboot

5. Verify Mount Point

#sudo df -hScreenshot showing df -h command output displaying disk usage and available space in Linux

Step 7: Extend Logical Volume
This command is used to add 2GB more in the current size of the logical volume.

#sudo lvextend -L +2G /dev/my_vg/my_lvScreenshot showing lvextend command used to increase logical volume size in Linux LVM

Command explanation

lvextend
·       This lvm command is used to increase the size of logical volume

-L +2G
·       Specifies the change in size and here it will add 2GB more in the current size of the Logical volume

/dev/my_vg/my_lv
·       Logical volume path which is created earlier

Summary
·       Lvm allocates the additional free space from the volume group
·       Extend the logical volume size
·       The block device becomes large

#sudo resize2fs /dev/my_vg/my_lvScreenshot showing resize2fs command used to expand ext4 filesystem in Linux

Step 8: Reduce Logical Volume
The process of reducing logical volume is bit more in length as compared to extend. First unmount the directory before reducing the logical volume.

#sudo umount /mnt/mydataScreenshot showing umount command used to safely unmount a filesystem in Linux

#sudo e2fsck -f /dev/my_vg/my_lvScreenshot showing e2fsck command used to check and repair ext4 filesystem in Linux

#sudo resize2fs /dev/my_vg/my_lv 4GLinux terminal output of resize2fs command resizing filesystem after logical volume extension

#sudo lvreduce -L 4G /dev/my_vg/my_lvScreenshot showing lvreduce command used to decrease logical volume size in Linux LVM

#sudo mount /dev/my_vg/my_lv /mnt/mydataScreenshot showing mount command used to attach a filesystem to a directory in Linux

Commands explanation:

Umount
·       Ensures file system is not in use

E2fsck
·       Checks and repairs file system before shrinking
·       Required for safety

Resize2fs
·       Shrink the file system to 4GB

Mount
·       Reattach the volume

LVM Snapshots Explained
Snapshots enable you to take a snapshot of the state of a volume. In this case it creates a snapshot of the logical volume /dev/my_vg/my_lv with the size of 1GB and name is snap_lv.

Create Snapshot
#sudo lvcreate --size 1G --snapshot --name snap_lv /dev/my_vg/my_lvLinux terminal output of lvcreate command creating a new logical volume from a volume group

Command explanation

lvcreate
·       lvcreate is used to create logical volume
·       Here it is used to create a snapshot volume

--size
·       Specifies the size of the snapshot
·       This is not the full size of the original volume
·       It is the space used to store changes (copy to write data)

--snapshot
·       This is used to create snapshot volume rather than a normal volume
·       Captures the state of the original volume at a specific time
·       It uses copy on write technology

--name
·       Assigns the snapshot name as snap_lv

/dev/my_vg/my_lv
·       Initially original and snapshot share the same data
·       When data changed on the original volume then old data is copied into the snapshot
·       Snapshot preserves the original state

Common Errors and Their Solutions in LVM
Even though LVM is powerful, users may encounter errors during the configuration and management. Below are some common issues along with their solutions.

1. Volume Group Not Found

Error
·       Volume group “my_vg” not found

Cause
·       Volume group does not exist
·       Incorrect vg name

Solution
Run “sudo vgdisplay” command to check the following
·       Verify the correct VG name
·       Use the correct name in your command

2. Logical Volume Already Exists

Error
·       Logical volume my_lv already exists

Cause
·       A logical volume with the same name already exists in the VG

Solution
Run the “sudo lvdisplay” command to check the following

#sudo lvdisplay

·       Check the existing logical volumes
·       Use a different name or remove the existing logical volume

#sudo lvremove /dev/my_vg/my_lv

3. Insufficient Free Space in Volume Group

Error
·       Insufficient free space available in volume group

Cause
·       All space may be already allocated and no space is available for new one

Solution
Run this command to check

#sudo vgdisplay

·       Check available space
·       Add more physical volume

#sudo vgextend my_vg /dev/sdd

4. File system not resized After Extending LV

Error
·       LV size increased but usable space didn’t change

Cause
·       File system was not resized

Solution
Run this command

#sudo resize2fs /dev/my_vg/my_lv

5.  Device Busy Error During Unmount

Error
·       Umount /mnt/mydata: target is busy

Cause
·       Directory is being used by the process

Solution
Run this command

#lsof +D /mnt/mydata
·       Identify the running processes
·       Stop them or use

#sudo umount -l /mnt/mydata

6. File system Corruption Warning

Error
·       File system needs to be checked

Cause
·       File system is inconsistent

Solution
Run this command

#sudo e2fsck -f /dev/my_vg/my_lv

7. Mount Fails (Wrong Files system Type)

Error
·       Wrong fs type, bad option or bad superblock

Cause
·       File system is not created or corrupted

Solution
Run this command

#sudo mkfs.ext4 /dev/my_vg/my_lv

Warning: this will erase data

8. Snapshot Runs Out of Space

Error
·       Snapshot becomes invalid

Cause
·       Snapshot size is too small

Solution
Run this command

#sudo lvcreate –size 2G –snapshot –name snap_lv /dev/my_vg/my_lv

·       Create snapshot of larger size

Management of storage also involves working with files and directories. To enhance your Linux skills, check out our guide on Effective Ways to Hide Files and Directories in Linux.

Real-World Use Cases of LVM

1. Server Environments
·       Manage growing storage needs dynamically

2. Cloud Infrastructure
·       Scale storage without downtime

3. Database Systems
·       Adjust storage based on data growth

4. Backup Systems
·       Use snapshots for quick recovery

Best Practices for Using LVM
  • Always keep backups before resizing
  • Use meaningful names for VG and LV
  • Monitor disk usage regularly
  • Avoid shrinking volumes unless necessary
  • Use snapshots wisely (they consume space) 
Pro Tips for Beginners
  • First practice in a virtual machine
  • Understand PV, VG and LV clearly
  • Avoid risky operations on production systems
  • Always verify commands before execution 

     FAQs about LVM in Linux

    1.  What is LVM in Linux?

     LVM is a flexible disk management system that allows dynamic storage allocation.

     2. Is LVM better than traditional partitioning?

    Yes, for most modern use cases due to flexibility and scalability.

    3. Can I resize LVM without reboot?

    Yes, in most cases, especially for extending volumes.

    4. Does LVM affect performance?

    Performance impact is minimal and usually negligible.

  • Basic Linux Commands Guide – 10 Basic Linux Commands Every Beginner Should know
  • Ways to Hide Files in Linux – Effective Ways to Hide Files and Directories in Linux
  • Linux System Performance with top and htop – Linux System Performance with top and htop
  •     Conclusion

        LVM in Linux is a powerful and flexible storage management solution that solves the limitations of traditional partitioning. It allows you to manage disks efficiently, dynamically scale the storage and perform the operations without downtime.

    If you are serious about Linux system administration then learning LVM is compulsory. Start practicing today and take full control of storage management of your Linux system.

    If you found this guide is helpful then explore the more Linux tutorials on the Seeklinux to master the system administration. Your feedback and comments are always be appreciated.

    SeekLinux Author
    SeekLinux Team
    Linux Engineers | DevOps | Security Enthusiasts

    SeekLinux Team shares practical Linux tutorials, SSL/TLS certificate guides, commands and DevOps solutions. Our goal is to simplify system administration and help you master real-world server and security tasks.

    Learn more about us →

    Post a Comment

    Previous Post Next Post