AWS, Cloud Computing

3 Mins Read

A Guide to Creating LVM Logical Volumes on AWS EBS and Resizing Them

Introduction

AWS provides a simple way to increase the size of your Amazon EBS volume. Before increasing the size of your EBS volume, it is a good way to back up your disk with an Amazon EBS snapshot.

If anything goes wrong, you can restore the volume anytime. To increase the flexibility of your web servers, you can later scale your web servers. This blog will help you increase the disk space of an Amazon EC2 instance.

Prerequisites

AWS Account

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Step-by-Step Guide

Step 1 – Backup EBS Volume

  1. Log in to your AWS account and go to EC2 service. Go to the Volumes tab under Amazon Elastic Block Store from the left side.
  2. It will give all the available EBS volumes there. Select the EBS volume of the instance you want to resize and click on the ‘Action’ button on top.
  3. Now it will ask for a description add, and in the last click on Create snapshot.
  4. Wait till the snapshot status changes to available. Move to the next section.

Step 2 – Create Physical Volume and add it to the Volume Group

  1. Execute the “gdisk” command to create a partition. For the variable Hex code or GUID, enter 8e00. In the below screenshot, we are creating the partition /dev/xvdf1 on /dev/xvdf.

step2

2. Now execute the “pvcreate” command to create a physical volume from the partition.

3. Run the “vgcreate” command to create a volume group to combine the new physical volumes.

4. Use the “vgdisplay” to view the volume group details.

Step 3 – Create a Logical volume and mount a directory

  1. To create a logical volume, run “lvcreate” command to create logical volumes (partitions) from your volume group(vg1).
  2. Run the “lvdisplay” command to view the logical volume created in the above step.

step3

3. Now create a directory using the “mkdir” command to mount the directory.

4. Execute the “mkfs -t” command to create the file system -t represents the target. Note: Replace xfs with your file system type if different. For example, use ext2, ext3, or ext4.

5. Run the “mount” command to mount the file system.

step3b

6. Edit “/etc/fstab” file so that the new mount remains permanent after reboot/ restart the machine.

step3c

Step 4 – Extend the Logical Volume

  1. Modify the size of the existing EBS volume.

step4

2. Now execute the “growpart” command to extend the partition, and then run the “pvresize /dev/xvdf1” command to resize the physical volume. In the below example, partition /dev/xvdf1 is extended.

step4b

3. To check physical volume details, execute the “pvdisplay” command. Use the “vgdisplay” to view the volume group details.

step4c

4. Run the “lvextend” command to extend the logical volume. Use the “lvdisplay” command to view the logical volume details.

Note: –

To increase the XFS filesystem size, the xfs_growfs command is used.

step4d

Conclusion

We can expand volume at any time according to demand. More volumes can be added to existing LVM volume instead of creating a snapshot of a volume and expanding it with improved performance and availability.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft Gold Partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding Amazon EBS Volume and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. What type of performance can I expect from Amazon EBS volumes?

ANS: – Performance depends on the type of EBS volume. Amazon provides a total of seven types of EBS volume Provisioned IOPS SSD (io2 Block Express, io2, and io1), General Purpose SSD (gp3 and gp2), Throughput Optimized HDD (st1), and Cold HDD (sc1).

2. Can we stripe multiple EBS volumes together to get better performance?

ANS: – Yes, you can stripe multiple EBS volumes together to get up to 260,000 IOPS or 60,000 Mbps (or 7500 MB/s) when attached to larger EC2 instance types.

3. What is an Amazon EBS snapshot?

ANS: – Amazon EBS snapshots are the backup of EBS volumes that help recover data on disk failure or loss.

WRITTEN BY Mayank Bharawa

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!