Table of contents
1.
Introduction
2.
Environment Setup
3.
Installation Steps
4.
Partitioning for LVM
5.
Assigning Mount Points
5.1.
What Just Happened?
6.
LVM Architecture and Terminology
6.1.
1. Physical Volumes (PV)
6.2.
2. Volume Groups (VG)
6.3.
3. Logical Volumes (LV)
6.4.
4. Physical Extents (PE) and Logical Extents (LE)
6.5.
5. LVM Snapshot
6.6.
6. Thin Provisioning
7.
Create Volume Groups and Logical Volumes
7.1.
Creating a Volume Group (VG)
7.2.
Creating Logical Volumes (LV)
8.
What Did We Achieve?
9.
Common Use Cases
9.1.
1. Resizing Partitions on the Fly
9.2.
2. Creating Snapshots
9.3.
3. Migrating Data Between Physical Disks
9.4.
4. Thin Provisioning for Efficient Space Utilization
9.5.
5. Managing Large Storage Pools
10.
Benefits in a Nutshell
11.
Frequently Asked Questions
11.1.
How does LVM enhance storage management?
11.2.
Can LVM be used for backup purposes?
11.3.
Is it possible to add new storage to LVM without downtime?
12.
Conclusion
Last Updated: Aug 13, 2025
Easy

Logical Volume Management

Author Rinki Deka
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Logical Volume Management (LVM) is like the architecture of your storage space, allowing you to resize and manage disk space on the fly. Especially for coding students, understanding LVM can be a game changer, offering a dynamic approach to managing storage resources in Linux environments. 

logical volume management

Let's embark on a journey to explore LVM, starting from setting up your environment to understanding its architecture and practical applications. 

Environment Setup

Before diving into the deep end of Logical Volume Management, let's set up our environment. This involves installing a Linux operating system, specifically Ubuntu, on an LVM partition. Why Ubuntu? It's user-friendly, widely used, and perfect for learners.

Installing Ubuntu on LVM Partition

Getting Started:

To start, you’ll need an Ubuntu installation media, like a DVD or a USB drive. You can download the latest Ubuntu ISO from their official website and create a bootable USB using tools like Rufus or Etcher.

Installation Steps

Boot from USB/DVD: Insert your bootable media and restart your computer. You'll need to access your system's boot menu or BIOS settings to boot from the media.

Start Ubuntu Installation: Once you boot from the USB or DVD, select 'Install Ubuntu'. You'll go through some initial prompts, like choosing the language and keyboard layout.

Partitioning for LVM

When you reach the “Installation type” screen, select “Something else” to manually partition your drive.

Create a new partition table if necessary.

Create a small partition for the boot loader. This should be a primary partition set to at least 500 MB, with a mount point of /boot.

Next, create a physical volume for LVM. Allocate the remaining disk space for this.

After creating the physical volume, you can now create a volume group and logical volumes within it.

Assigning Mount Points

Assign mount points to your logical volumes. Commonly, you would at least create a root (/) and swap area.

Continue the installation process by selecting your time zone, creating a user, etc.

Finalizing Installation:

Once you complete these steps, Ubuntu will install. After installation, restart your computer, and if everything went correctly, you’ll boot into your new Ubuntu installation on an LVM partition.

What Just Happened?

By installing Ubuntu on an LVM partition, you've just set up a flexible system where you can later resize partitions, create snapshots, and manage disk space more efficiently.

LVM Architecture and Terminology

Understanding the architecture and terminology of Logical Volume Management is crucial for effectively utilizing its features. LVM is a bit like playing with building blocks, where you can construct and restructure storage space as needed.

1. Physical Volumes (PV)

These are your physical hard drives or partitions that you allocate for LVM use. Think of them as the raw materials in your storage construction kit.

2. Volume Groups (VG)

A volume group is a pool of storage that is made up of one or more physical volumes. You can think of a VG as a big tank of storage space that you can allocate from.

3. Logical Volumes (LV)

Within a volume group, you create logical volumes. These are the segments of your tank (VG) that your operating system sees as regular partitions. They're flexible and can be resized as needed.

4. Physical Extents (PE) and Logical Extents (LE)

Both PVs and LVs are divided into extents, which are chunks of data of a fixed size. PEs are on the physical volume, and LEs are on the logical volume. The extents are mapped from the PV to the LV.

5. LVM Snapshot

This is a special type of LV, a read-only copy of a logical volume at a certain point in time. It's like taking a photo; you capture the state of your data at a specific moment.

6. Thin Provisioning

This is an advanced feature of LVM that allows you to create LVs that are larger than the available physical storage in your VG. It's like committing to building more rooms in your house than you currently have bricks for, betting that you'll get more bricks by the time you need to build.

Create Volume Groups and Logical Volumes

After grasping the architecture and terminology, let's roll up our sleeves and get practical. We'll create Volume Groups (VGs) and Logical Volumes (LVs). This process is like allocating and organizing the space in your storage 'house'.

Creating a Volume Group (VG)

First, ensure you have a physical volume (PV). If you haven't already created a PV during the Ubuntu installation, you can convert a whole disk or a partition into a PV using the pvcreate command.

sudo pvcreate /dev/sdaX

Replace /dev/sdaX with your specific disk or partition.
 

Create a Volume Group:

Use the vgcreate command to create a new VG. You can add one or more PVs to this VG.

sudo vgcreate my_volume_group /dev/sdaX

Here, my_volume_group is the name of your new VG.

Creating Logical Volumes (LV)

Determine Size and Purpose:

Decide how much space you want for your LV and what it will be used for (like /home, /var, or others).
 

Create Logical Volume:

Use the lvcreate command. You'll need to specify the size, name, and VG it belongs to.

sudo lvcreate -L 20G -n my_logical_volume my_volume_group


This command creates an LV named my_logical_volume of 20GB in my_volume_group.

Format and Mount the Logical Volume:

After creating the LV, format it with a file system (like ext4) and mount it.

sudo mkfs.ext4 /dev/my_volume_group/my_logical_volume
sudo mount /dev/my_volume_group/my_logical_volume /mnt


Now, your LV is ready to use!

What Did We Achieve?

By creating VGs and LVs, you've just set up a flexible storage space that can be easily adjusted to your needs. You can extend or reduce LV sizes, add new disks to VGs, or even move data between different LVs without much hassle.

Common Use Cases

LVM shines in scenarios where flexibility and scalability in storage management are essential. Let's explore some of the most common use cases where LVM proves to be an invaluable tool.

1. Resizing Partitions on the Fly

One of the most significant advantages of LVM is the ability to resize partitions without needing to unmount them. This is particularly useful in dynamic environments where data storage needs frequently change. You can increase the size of a logical volume using the lvextend command and decrease it with lvreduce, followed by resizing the filesystem.

2. Creating Snapshots

Snapshots are essentially read-only copies of a logical volume at a specific point in time. This is extremely useful for backups or for testing updates/changes without affecting the original system. You can create a snapshot with the lvcreate command and specify the size that will be used to store changes.

3. Migrating Data Between Physical Disks

With LVM, you can move data from one physical disk to another without downtime. This is particularly handy when upgrading to larger disks or replacing old ones. The pvmove command allows you to migrate data between physical volumes.

4. Thin Provisioning for Efficient Space Utilization

Thin provisioning is an advanced feature of LVM that allows you to allocate more space to logical volumes than physically available in your volume group. This is useful in situations where you need to overcommit storage resources, like in virtualization scenarios.

5. Managing Large Storage Pools

LVM is excellent for managing large amounts of storage. By combining multiple physical disks into a single volume group, you can create a large pool of storage that is easier to manage and allocate from.

Benefits in a Nutshell

  • Flexibility: Adjust storage allocations as needs change without disrupting operations.
     
  • Efficiency: Optimize the use of available disk space.
     
  • Convenience: Simplify storage management with abstracted, logical volumes.

Frequently Asked Questions

How does LVM enhance storage management?

LVM provides unparalleled flexibility, enabling easy resizing of storage volumes and snapshot creation without system disruption, ideal for environments with changing storage demands.

Can LVM be used for backup purposes?

Yes, LVM's snapshot feature allows for creating consistent backups of volumes without halting system operations, making it a practical tool for data protection strategies.

Is it possible to add new storage to LVM without downtime?

Absolutely, LVM allows the addition of new storage devices into existing volume groups seamlessly, ensuring continuous system operation and scalability of storage resources.

Conclusion

Logical Volume Management stands out as a powerful tool in the realm of storage management. Its ability to offer dynamic resizing, easy snapshot creation, and the seamless addition of new storage solutions addresses many of the limitations found in traditional partitioning methods. For coding students and budding system administrators, mastering LVM equips them with the skills to manage storage resources efficiently in various scenarios, from simple desktop systems to complex server environments. By understanding and applying LVM, one can ensure data integrity, system flexibility, and optimize storage utilization, making it an indispensable skill in modern computing.

You can refer to our guided paths on the Coding Ninjas. You can check our course to learn more about DSADBMSCompetitive ProgrammingPythonJavaJavaScript, etc. 

Also, check out some of the Guided Paths on topics such as Data Structure and AlgorithmsCompetitive ProgrammingOperating SystemsComputer Networks, DBMSSystem Design, etc., as well as some Contests, Test Series, and Interview Experiences curated by top Industry Experts.

Live masterclass