Unleashing Storage Flexibility: A Hands-on Guide to LVM Powerhouse

Priyanshu Bhatt
7 min readJun 25, 2023

In the realm of server Administration, managing storage resources efficiently and effectively is paramount. The ability to dynamically allocate, resize, and distributed storage volumes without dirupting system operations is a critical requirement for many IT professional.Logical Volume Storage is an ingenious solution that brings enhanced flexibility and control to linux server environments.

In this Blog, we will dive deep into the world of LVM and explore its practical Implementation in real life. Whether you are a system administrator, A Devops Engineer, or simply curious about Linux Server Management, this article aims to highlight the use of it.

Lets start the adventure now!

Setting Up a New Sata Hard disk

The first step of setting up the Logical Volume in your environment is to attach some additional disk space for the allocation.

STEP1: Open the Settings of the Virtual Machine in the Oracle Virtual Box and Click on the Storage.

STEP2: Click on the “+” to create a new SATA Hard disk for This Virtual Machine.

STEP 3: Click on the Create Button.

STEP4: Select Virtual Disk Image from the radio options and do Next.

STEP 5: Choose the location and size you want to allocate. Here are 5 GB and 6GB.

STEP 6: Attach the previously created disks.

STEP 7: After you Add the disk , The list of disk will appear below.

After the above step, you will be able to see the new hard disk in your VM, /dev/sdb is 5GB and /dev/sdc is 6 GB.

fdisk -l

Before starting with the setup let’s discuss some Key Terminologies in LVM.

Logical Volume Manager

LVM is very important way of effectively managing the storage volumes in Linux Servers by abstracting the physical storage devices into Logical Volumes. This way of management allows easy resize, shrink and extend facility which helps resizing the server at the time of resource utilization. LVM also offers features like Volume Striping and Mirroring which enhances the read and write operations and provide data protection.LVM follows levels of volume provisioning using Physical Volume(PV) and Volume Groups(VG).

Physical Volume(PV): Physical Volume is a fundamental component of LVM which can contain physical storage devices, partitions, etc. It's the first stage of creating A LVM as multiple hard disks are converted to Physical Volumes which when combined creates a group that acts as a building block for higher-level LVM components. The Size of a Physical Volume is the size of the underlying disk.

Volume Groups(VG): Volume Group contains multiple Physical Volume, It provides a way to allocate storage in a flexible manner. At times when we need to increase the LV size, adding newer Physical Volume in the existing Volume Group can do the job. Volume Groups also allow Mirroring and Striping of the Logical Volume(LV). Apart from all the storage allocation and extension power, Volume Groups also enables Snapshots and Backups for the LV.

Logical Volume(LV): Logical Volume is the end product of Physical Volume and Volume Groups. It is a virtual block of devices that resides within the Volume Group. It represents a logical Partition or volume that can be formatted like a file system and mounted like a regular disk partition. LV is created from the VG.

Creating Physical Volume from Hard Disk

Creating Physical Volume is the first step for creating an LV, Here we are going to create two Physical Volumes of size 5GB and 6GB.

STEP1: Creating PV for /dev/sdb hard disk

pvcreate /dev/sdb

STEP2: Creating PV for /dev/sdc hard disk.

pvcreate /dev/sdc

Now to display the details of the PV you will use pvdisplay command

pvdisplay /dev/sdb
pvdisplay /dev/sdc

The above picture shows that the PV of size 5GB from the /dev/sdb has been successfully created.

Creating Volume Group from the Physical Volumes.

In the above step, you created the Physical Volume, now you’ll create a Volume Group from the above PV.

vgcreate priyanshuvg /dev/sdc /dev/sdd

Vgcreate is a command used to create Volume groups and takes the Physical Volumes as input, You can add any number of Physical Volumes to a Volume Group. To display the details use the vgdisplay command

vgdisplay priyanshuvg

Vgdisplay shows the combined size of both the Physical Volume (5+6=10GB).

Creating a Logical Volume

LV can be created easily using the lvcreate command by specifing the size of the LV, you can create multiple LV in a Volume Group.

lvcreate --size 5G --name mypriyanshulv priyanshuvg

This created a Logical Volume of 5GB size, what if you give size more than the size of the Volume Group?

lvcreate --size 11G --name mypriyanshulv priyanshuvg

This will result into error as we cannot create LV of size more than VG. To display the details of the LV use the lvdisplay command

lvdisplay priyanshuvg/priyanshulv

There are default LVs in the system, which are leverage the power of Logical Volume Manager.

The output shows root and Home as LV

Using Logical Volume

To use a Logical Volume, you have to follow the partitioning steps of formating and mounting.

STEP 1: Creating an MountPoint.

mkdir /bloglvm

STEP2: Formating it using the mkfs.ext4 type

mfs.ext4 /dev/priyanshuvg/mypriyanshulv

STEP3: Mounting it to the /bloglvm mount point

mount /dev/priyanshuvg/priyanshulv /bloglvm

Now any file created in the /bloglvm folder will be created in the lVM partition.

Increasing The Size of the LV

One of the greatest use of LVM is to increase and decrease the Size of the disk without getting Downtime. LVM allows for dynamic allocation and resizing of the logical Volumes, providing flexibility in managing the storage space. This can be a very important part of a server that requires changing storage over time.

To increase the size of the LV you must have the desired amount of space in the Volume Groups or you can add more Physical volume to an existing Volume Group to increase the size of VG.

STEP 1: Use the lvextend command to extend the size.

lvextend --size +4G /dev/priyanshuvg/priyanshulv

This one command will increase the size of the LV by 4GB.

To display the details of the Updated LV use lvdisplay

lvdisplay /dev/priyanshuvg/priyanshulv

lvdisplay command shows that the size has been increased but when we do df -h it shows the previous size.

This is because df -h only shows the formatted part of the disk and the newly added is not yet formatted. So format the added 5GB space using the resize2fs command; resize2fs implements online resizing which resizes file systems while they are still mounted and in use. Resize2fs only formats the unformatted part of the filesystem.

STEP2: Resizing the Logical Volume using resize2fs

resize2fs /dev/priyanshuvg/mypriyanshulv

Now df -h also shows the full size of the Volume.

What if your Volume Group size is less than the amount you want to increase the size, Then you have to increase the size of the Volume Group by adding more Physical Volumes to it.

vgextend priyanshuvg <NEW_PV_DEVICE_NAME>


Implementing LVM(Logical Volume Manager) in your Linux server is of significant importance for efficient storage management in your environment. Changing demand for Traffic Management and Workload management has increased and there are multiple tools to solve the problems but by utilizing core concepts like LVM you can become more efficient in your day-to-day work. To learn more about Linux check Out my NFS-Storage Blog.

Thanks For Reading!



Priyanshu Bhatt

AWS Solutions Architect || Terraform Certified Associate || DevOps Engineer || I Share Crisp Tech Stories linkedin.com/in/priyanshubhatt