How do I expand the Amazon EBS root volume of my Amazon EC2 Windows instance?

Last updated: 2022-07-10

I've run out of space on my Amazon Elastic Compute Cloud (EC2) Windows instance. How can I dynamically expand the Amazon Elastic Block Store (Amazon EBS) volumes of my Windows instances?

Resolution

An Amazon EC2 Windows instance created from an Amazon Machine Image (AMI) has a default 30 GB gp2 (General Purpose SSD) Amazon EBS root volume. You can expand the disk space of a Windows instance following these steps.

1.    Expand the EBS volume attached to a Windows instance using the Amazon EC2 console or the AWS Command Line Interface (AWS CLI).

2.    Extend the volume’s file system at the operating system level using Disk Management or PowerShell.

Expanding the EBS volume

EBS volume can be expanded using Amazon EC2 console or AWS CLI.

Note: Windows root volumes are the master boot record (MBR) by default and can be extended up to 2 TB.

Expanding the EBS volume using the old Amazon EC2 console

1.    From the Amazon EC2 console, choose Instances from the navigation pane.

2.    Select the instance that you want to expand. From the Description tab, click on the Block devices name. Then, choose the EBS ID.

3.    Select the volume. From Actions, choose Modify Volume.

4.    In the Size field, enter the Size and IOPS based on the volume type.

5.    Choose Modify, and then choose Yes. Refresh the console page. In the Description tab, the State shows the progress of optimization if the modification call is successful. You can proceed to Step 2 when the volume enters optimizing state.

Expanding the EBS volume using the new Amazon EC2 console

1.    From the Amazon EC2 console, choose Instances from the navigation pane.

2.    Select the instance. From the Storage tab, choose the EBS Volume ID.

3.    Select the volume. From Actions, choose Modify Volume.

4.    In the Size field, enter the Size and IOPS based on the volume type.

5.    Choose Modify, and then choose Yes. Refresh the console page. In the Description tab, the State shows the progress of optimization if the modification call is successful. You can proceed to Step 2 when the volume enters optimizing state.

Expanding the EBS volume using AWS CLI

Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent AWS CLI version.

Expanding the EBS volume can be done by the CLI command modify-volume. Run a command similar to the example command here. Replace the with your values:

aws ec2 modify-volume --region <regionName> --volume-id <volumeId> --size <newSize> --volume-type <newType> --iops <newIops>

Note: To view the progress of your task, run the following command:

aws ec2 describe-volumes-modifications --volume <volumeId> --region <region>

Extending the volume space at Operating System level

The Amazon EBS volume attached to an instance can be extended using Disk Management or PowerShell.

Extending the file system using Disk Management

1.     Connect to your EC2 Windows instance using Remote Desktop Protocol (RDP).

2.    Open a command prompt, and then run the diskmgmt.msc command to launch Disk Management. From Action, choose Refresh.

3.    Open the context (right-click) menu for the Volume, and then choose Extend Volume.

4.    Choose Next, Next, Finish.

Repeat these steps for any additional volumes.

Extending the file system using PowerShell

1.    Connect to your EC2 Windows instance using Remote Desktop Protocol (RDP).

2.    Run PowerShell as an administrator.

3.    Run the Get-Partition command. PowerShell returns the corresponding partition number for each partition, the drive letter, offset, size, and type. Note the drive letter of the partition to extend.

4.    Run the following command to rescan the disk:

"rescan" | diskpart

5.    Run the following command, using the drive letter you noted previously. Replace the with your values. PowerShell returns the minimum and maximum size of the partition allowed, in bytes.

Get-PartitionSupportedSize -DriveLetter <drive-letter>

6.    To extend the partition to a specified amount, use the following command, entering the new size of the volume in place of . You can enter the new size in KB, MB, or GB.

Resize-Partition -DriveLetter <drive-letter> -Size <new-size>

For example if the old size is 30 GB and you want to extend by 2 GB, the value for new-size is 32 GB.

To extend the partition to the maximum available size, run the following command:

Resize-Partition -DriveLetter <drive-letter> -Size $(Get-PartitionSupportedSize -DriveLetter <drive-letter>).SizeMax

For more information, see Extend a Windows file system after resizing a volume.

Note: Before extending a file system that contains valuable data, it's best practice to create a snapshot of the volume that you can use to roll back your changes. For more information, see Create Amazon EBS snapshots.


Did this article help?


Do you need billing or technical support?