noobie.cloud

Back

Extend LVM and Volumes on AWS EC2Blur image

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#


  1. Go to your AWS ConsoleEC2Volumes.

  2. Select the volume attached to your EC2 instance.

  3. Click Modify Volume, enter the new size, and confirm.

  4. Wait for the resize to complete (you can check with lsblk).

Step 2: Resize the Partition#


If you’re using LVM, follow these steps:

  1. Check the current disk and volume groups:

    lsblk
    df -h
    vgs
    lvs
    plaintext
  2. Identify the new disk space and inform the kernel:

    sudo growpart /dev/xvdf 1  # Replace xvdf with your actual device
    plaintext
  3. Extend the Physical Volume (PV):

    sudo pvresize /dev/xvdf1  # Use correct partition name
    plaintext
  4. Extend the Logical Volume (LV):

    sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv  # Adjust path accordingly
    plaintext
  5. Resize the Filesystem:

    • If using ext4:

      sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
      plaintext
    • If using XFS:

      sudo xfs_growfs /
      plaintext

Step 3: Verify Changes#


Run:

lsblk
df -h
plaintext

You 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! 😎

Extend LVM and Volumes on AWS EC2
https://noobie.cloud/blog/extend-volumes-on-aws-ec2
Author noobiecloud@protonmail.com
Published at February 16, 2024
Comment seems to stuck. Try to refresh?✨