fbpx

How to increase the size of an EBS Volume attached to a Windows Instance

How to increase the size of ebs volume windows ec2
AWS offers persistent storage for Amazon EC2 instances through EBS volumes. Learn how to increase the size of an EBS Volume attached to a Window instance.
Share This Post

Step-by-Step Instructions This article demonstrates how to increase the size of an EBS volume that is attached as a root device to an EC2 instance with a Windows Server 2012 OS. In the example below, an EC2 Windows instance is launched with a 30GB root device.

n2ws

The information in the screenshot above assumes the you have setup the CLI in a local machine. When you want to check the details of a volume, use the following command: aws ec2 describe-volumes Take note of the DeleteOnTermination flag’s attribute value for the volume as you may need to set the same value for the new volume.

n2ws

Here, you can take a snapshot and create a new, larger, 50GB volume in same Availability Zone. The new volume can then be attached as a root device to the instance after temporarily stopping that instance. For demonstration purposes, the size of this root device will be increased, however the same steps can be applied to any volume attached to an EC2 instance. If the volume is not a root device, the instance does not have to be stopped, but AWS does recommend disconnecting or unmounting the device before taking snapshots so as to prevent the application from crashing if the process gets stuck along the way.

The easier way to protect EBS volumes
Try N2WS Backup & Recovery to:

After the Windows instance is launched, connect to it via RDP. (Note: Ensure that you have already allowed remote connections on the Remote tab in the system properties wizard.)

n2ws

Once you have logged into the system, go to Server manager > File and Storage services > Disks, as shown below. The Disks section shows that the size of the drive is 30GB.

n2ws

Next, stop the running instance as shown below or using CLI. (If this is not a root volume/device, there is no need to stop the instance.)

n2ws

Using CLI:

aws ec2 stop-instances --instance-ids 

n2ws

Detach the volume from the previously stopped instance as shown below or using CLI.

n2ws

Using CLI:

aws ec2 detach-volume --volume-id 

n2ws

Create a snapshot from the selected Windows volume as shown below or using CLI.

n2ws

Using CLI:

aws ec2 create-snapshot --volume-id --description "" 

n2ws

Provide the appropriate details while creating the snapshot.

n2ws

Create the volume from a previously generated snapshot. Remember to take note of the previously launched instance’s AZ.

n2ws

Next, resize the volume from 30GB to 50GB. Specify the AZs and select the type of volume. (Note: The volume must be created in the AZ where the present instance is in a stopped state. If the volume and the instance are in different zones, they cannot be attached.)

n2ws

Using CLI:

aws ec2 create-volume --size 50 --region us-east-1 --availability-zone us-east-1a --snapshot-id --volume-type <gp2/io1/Default is standard> 

n2ws

We created IOPS volume with the command above. You can also create General Purpose or Magnetic (standard) volumes, as needed.

Attach the new volume to the stopped instance as shown below or using CLI.

n2ws

Using CLI:

aws ec2 attach-volume --volume-id --instance-id --device /dev/sda1 

n2ws

Start the instance after the new root volume has been attached.

n2ws

Using CLI:

aws ec2 start-instances --instance-ids 

n2ws

Connect to the Windows instance using RDP (mstsc).

n2ws

Log onto the Windows server again and go to Server manager > File and Storage services > Disks, as shown below. The Disks section shows that the size of the drive is now 50GB.

n2ws

The original volume was 30GB and we increased it by creating a new 50GB volume. So, the 20GB increase is still unallocated. If you want to enlarge the volume to 50GB by allocating this 20GB, go to Disk Management Utility, select the drive (in this case, the C Drive), rIght-click and select Expand. (Note: If you do not need the old volume (original 30GB), then delete it to save costs.)

After the volume is created, we advise changing the DeleteOnTerminate flag as needed. You can set the flag with CLI, as shown below:

aws ec2 modify-instance-attribute --instance-id --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\",\"Ebs\":{\"DeleteOnTermination\":false}}]"

n2ws

In order to check the volume flag (as shown above), use the command:aws ec2 describe-volumes –volume-idWe also recommended deleting the original volume (detached in step#4).

Again, the steps outlined above show how the size of a root volume can be increased from 30GB to 50GB. These steps can be easily followed to increase the size of any attached EBS volumes. As previously mentioned, if the volume is not a root volume, you don’t have to stop the instance. (Note:

If you do not want to use the snapshot or old volume, it can be removed to save costs.)
EBS snapshots are very handy when it comes to point-in-time backup because they achieve high availability and disaster recovery. In this article, we used snapshots to change the size of an EBS volume.

N2Ws offers a solution that enables you to further simplify the process of using snapshots. N2WS Backup & Recovery (CPM) is an enterprise-class backup, recovery, and disaster recovery solution for the EC2 compute cloud. CPM is available as a service model that allows users to manage multiple AWS accounts and configure policies and schedules to take automated snapshot backups. It also has a Windows agent to consistently back up Windows applications. CPM allows you to recover a volume from a snapshot, increase its size and switch it with an existing volume for an instance, in a single step.

Read Also

Next step

The easier way to protect EBS volumes

Allowed us to save over $1 million in the management of AWS EBS snapshots...

Try N2WS for Free