Linux Tutorial: Online Resize of an AWS EBS Volume – Ubuntu AMI

By |Published On: January 8th, 2019|Tags: |

Scenario: You have a running EC2 Linux instance, and need more disk space added to an EBS volume. You don’t want to shut the instance down. How do you do this?

At Hurricane Labs, we manage a number of Splunk environments running within Amazon Web Services (AWS), as well as extensively use it internally for our operations. We’ve needed to perform this process several times for customers and ourselves, and figured that the best place to document the process would be here, so that it benefits more than just us.

The screencast will walk you through the process, but this is a simple process when using logical volume manager (LVM).

1 – First, confirm that you are using LVM and identify the drive you are looking to expand. This can be done with the pvs and lvs commands.

In this example, the disk to expand is named /dev/xvdf. It’s currently 2gb in size and mounted at /opt/splunk.

2 – Locate your EC2 instance in the AWS console, and in the details tab, examine the section for Block devices. Identify the drive that is associated with the volume you are looking to expand.

Note: This may vary based on the operating system in use. In this case, /dev/sdf in the AWS console corresponds to /dev/xvdf in the Ubuntu AMI. Generally the last letter of the device name should match, but that’s not always the case for every device and OS combination.

3 – Click on the Block device name, and then click on the EBS ID that is displayed when the block device is selected.

4 – This will take you to the EBS volume details for the disk you are looking to expand:

5 – Click on Actions -> Modify Volume, and change the size of the volume to the desired capacity.

6 – Confirm the volume modification.

7 – The new volume size will now be reflected in the AWS console.

8 – Back on the target system’s operating system, run the parted command to confirm that the correct/newly expanded size is shown. In this example we’ll see that the 10gb size is listed.

9 – Run the pvresize command to grow the physical volume associated with the EBS volume that was expanded:

10 – Run the pvs command to confirm that the new size is shown:

11 – Run the lvextend command to grow the logical volume:

12 – Expand the file system to use the new space. In this case, using XFS, this is done with the xfs_growfs command:

13 – You’re all set, and ready to use the new space you just added:

Once these steps are completed, you should be back in business – no reboots or other changes are required, and the disk is ready to use. Hopefully this was helpful in demonstrating the flexibility of AWS to handle growth in your storage needs without any downtime to the running systems.

Share with your network!
Get monthly updates from Hurricane Labs
* indicates required

About Hurricane Labs

Hurricane Labs is a dynamic Managed Services Provider that unlocks the potential of Splunk and security for diverse enterprises across the United States. With a dedicated, Splunk-focused team and an emphasis on humanity and collaboration, we provide the skills, resources, and results to help make our customers’ lives easier.

For more information, visit www.hurricanelabs.com and follow us on Twitter @hurricanelabs.