Extend LVM and Volumes on AWS EC2
Manage storage on AWS EC2 easily with LVM
Easily Extend LVM and Volumes on AWS EC2#
Managing storage on AWS EC2 can be a daunting task if you’re new to Linux volume management. But with LVM (Logical Volume Manager), resizing your storage dynamically becomes easy and efficient. In this guide, we’ll walk through the process of extending an EBS volume and resizing an LVM partition without downtime.
Step 1: Extend the EBS Volume#
-
Go to your AWS Console → EC2 → Volumes.
-
Select the volume attached to your EC2 instance.
-
Click Modify Volume, enter the new size, and confirm.
-
Wait for the resize to complete (you can check with
lsblk
).
Step 2: Resize the Partition#
If you’re using LVM, follow these steps:
-
Check the current disk and volume groups:
plaintextlsblk df -h vgs lvs
-
Identify the new disk space and inform the kernel:
plaintextsudo growpart /dev/xvdf 1 # Replace xvdf with your actual device
-
Extend the Physical Volume (PV):
plaintextsudo pvresize /dev/xvdf1 # Use correct partition name
-
Extend the Logical Volume (LV):
plaintextsudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv # Adjust path accordingly
-
Resize the Filesystem:
-
If using ext4:
plaintextsudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
-
If using XFS:
plaintextsudo xfs_growfs /
-
Step 3: Verify Changes#
Run:
lsblk
df -h
plaintextYou should now see the increased disk size available for use!
Conclusion#
With LVM, extending storage on an AWS EC2 instance is seamless. No need to restart the instance, making it a great approach for production systems. Hope this guide helps---happy scaling! 🚀
For more AWS & DevOps tips, stay tuned to noobie.cloud! 😎