How to Expand the Storage Space of Volumes for EC2 Instance

Many of us using AWS for website hosting and other online activity such as app development and storage but in this lesson we are talking about increasing the space of EBS volumes for EC2 Instance.Expanding the storage space of Volumes for Ec2 Instance is not complicated its so simple and easy you have to follow some simple steps given below to complete the task.You can increase the space of an existing EBS volume without losing the data.Here we are not talking about its pricing you can check it on AWS official website on the Amazon EC2 Pricing.

Before migrating  the data on a larger volume we have to check the Instance shutdown behavior for that you need to log in at Amazon EC2 console now navigate to the Instance and select the Instance with the volume that you want to expand and make a note of the Instance ID and Availability Zone (required this information when you will attach a new volume to the Instance).

Now check the Shutdown behavior which should be set to Stop and not Terminate for that choose the instance now go to instance setting from the context menu and then select Change Shutdown Behavior if the Shutdown behavior is set to terminate, choose stop and if the shutdown behavior is already set to Stop then choose cancel.

Create A Snapshot of the Existing Volume to Expand

  • Go to Volumes and then select the volume you want to expand.
  • Now go to context-Menu (right-click) choose Create Snapshot.
  • Now fill the details for Name and Description field and then click on Yes, Create.

Create A New Volume From Snapshot

  • Go to Snapshots section and when the status of Snapshots (You have created in previous steps) is set to complete, choose the snapshot and Create Volume.
  • Now a Create Volume dialog box will pop-up select the desired volume type (SSD, Magnetic etc) and enter the new volume size now set the Availability Zone to match the Instance Availability Zone and choose yes, Create button (Here it is important to note that you need to set the availability zone to match with Instance’s availability zone).

Detach the Old Volume

  • Go to volumes in the navigation pane and then select the old Volume from the list and note down the device name in the Attachment Information field.
  • Now from the context menu select the old volume and select Detach Volume.
  • Now in Detach volume dialog box choose Yes Detach it will take some time.

Attach the New Volume

  • Go to Volumes in the navigation pane.
  • Then choose the new volume and select the Attach Volume from the context menu.
  • Now type the name or ID of the instance in the Instance field then select the instance.
  • Now enter the same device name (Which you previously not down) and choose Yes, Attach and important things is that the volumes need to be reattached to the exact location it was detached from (for example /dev/sda1).

Restart the Instance

  • Go to your Instance section on AWS navigation pane and choose the instance you want to restart.
  • Now from the context menu choose instance state and then choose Start.
  • In the start instance dialog box, choose Yes, Start.

If everything is properly configured as according to this lesson you Instance will restart with new volume size in case if your instance fails to start you have checked that you have attached the expanded volume using the same device name as the original volume for example /dev/Sda1.

Leave a Reply