Home AWS How to Create a Logical Volume Manager (LVM) on AWS EBS?

How to Create a Logical Volume Manager (LVM) on AWS EBS?

by SupportPRO Admin

This documentation will show you how to create an LVM partition on an AWS EBS volume. 

LVM is a storage virtualization technology that offers a flexible way to manage disk space. Using LVM we can have multiple virtual partitions on a physical volume or a single virtual partition over numerous physical volumes. 

1. Deploy an EC2 instance 

  1. Login to your AWS management console and search for EC2.
  2. On the EC2 dashboard, click Launch Instance to deploy a virtual machine.
  3. Provide an instance name and choose the OS image, key pair,  instance type, etc.
  4. Review the configuration, storage, tagging, and security settings selected for your instance.
  5. And click on the Launch button at the bottom of the page.

2. Create Elastic Block Store-EBS volume and attach it to the EC2 instance.

  1. On your EC2 dashboard, select the option “Volumes” under “Elastic Block Store”
  2. Click on the button “Create volume”.
  3. Choose the volume type, size, availability zone, and other required settings. Make sure you choose the same availability zone where your instance resides. 
  4. Click on the create button
  5. Now choose the volume created and attach it to the EC2 instance. 

3. Verify that the EC2 instance recognizes the attached volume. 

  1. Login to the EC2 instance using SSH
  2. Execute lsblk command and verify that the attached volume is available.

4. Create a Physical Volume – PV  from the EBS volume

Set up the device to use the LVM. To do this, we can use the pvcreate command. The pvcreate command is used to initialize the disk or partitions that will be used by the LVM. It can either initialize a complete physical disk or a partition on a physical disk. 

  1. Here we use the volume /dev/xvdf to create the physical volume. 
  1. Use pvdisplay command to the physical volume details.

5. Create a Volume Group (VG) and add physical volume to the volume group. 

  1. Use the command vgcreate to create a volume group and add a physical volume to it.
  1. Use the command vgdisplay to display the volume group details.

6. Create a Logical Volume and mount the directory 

  1. Use the command lvcreate to create a logical volume from the volume group.
  1. Use the command lvdisplay to see the logical volume details 
  1. Create a mount point using mkdir command 

# mkdir mnt1

  1. Use mkfs -t command to create the file system.

#mkfs -t xfs /dev/volume-group/logical-volume1

  1. Run lsblk -f command to verify the file system.
  1. Run mount command to mount the file system to the mount directory.

# mount /dev/volume-group/logical-volume1 /mnt1

You can verify the volume mounted to the directory using df -h command.

Upon successful creation and mounting of the Logical Volume Manager (LVM), it can be utilized as a conventional volume. Notably, the LVM offers various benefits to business operations, including improved performance and the ability to expand as required. By dispersing data across multiple Elastic Block Store (EBS) volumes using LVM, companies can leverage the dedicated network throughput between Amazon Web Services (AWS) Elastic Compute Cloud (EC2) and EBS, resulting in superior network throughput compared to a single network channel between EC2 instances and EBS volumes. Additionally, companies can effortlessly expand their volume by adding more EBS volumes to the existing LVM volumes, instead of creating an EBS volume snapshot and subsequently expanding it.

guy server checkup

Need help with your servers?

Contact Us today!

Leave a Comment


Sales and Support

Phone: 1-(847) 607-6123
Fax: 1-(847)-620-0626
Sales: sales@supportpro.com
Support: clients@supportpro.com
Skype ID: sales_supportpro

Postal Address

1020 Milwaukee Ave, #245,
Deerfield, IL-60015

©2022  SupportPRO.com. All Rights Reserved