Increase size of Amazone ec2 instance


Step by Step
This article demonstrates how one of our users increased a root EBS volume from 8GB to 30GB.
In order to accomplish this, we will show you how once you launch a Linux-based EC2 instance, you can increase the size of your EBS volume using snapshots. All you need to do is launch an instance, create a snapshot from the volume that is attached to the launched instance, then create a new, bigger volume.
 
Below is a step by step guide that will clarify how to perform this task:
  1. First, you need to successfully launch an EC2 instance with EBS as its root device. The root EBS volume is used as a reference, so you can follow the same step for all of the volumes.
    n2ws
  2. Next, connect the instance via PuTTY (in Windows machines) or an SSH client (in Linux machines). We are using PuTTY for our exercise.
    n2ws
  3. Run the command “df –h”. It will display the drive’s details before resizing.
    n2ws
  4. To increase the size of the root volume, since this is an EBS-backed instance, first stop the instance temporarily.
    n2ws

    Using CLI:
    ec2-stop-instances i-bc781c50
    (assuming that the AWS CLI has already been set up on your machine.)
    n2ws
  5. Detach the existing volume from the instance.
    n2ws

    Using CLI:
    ec2-detach-volume vol-47b0d203
    n2ws
  6. Create a snapshot from the previously detached volume.
    n2ws

    Using CLI:
    ec2-create-snapshot vol-47b0d203 --description "Daily Backup"
    n2ws
  7. Provide an appropriate name for the snapshot.
    n2ws
  8. Details of the recently created snapshot can be found under the description tab in the snapshot area.
    n2ws
  9. Create a volume from the recently generated snapshot.
    n2ws

    Using CLI:
    ec2-create-volume --size 30 --region us-east-1 --availability-zone us-east-1a --type gp2
    Note: In this case, the us-west-2 region is selected in the CLI instead of us-east-1 because the instance is running in US West.
    n2ws
  10. Now, you can resize the volume. Here, the user resized it from 8GB to 30GB. All you have to do is specify the AZs and select the type of the volume you need. (Note: The volume must be created in the AZ where the present instance is in a stopped state. Otherwise, if the volume and the instance are in different zones they cannot be attached.)
    n2ws
  11. Attach the new volume to the running instance.
    n2ws

    Using CLI:
    ec2-attach-volume vol-7bea883f -i i-bc781c50 -d /dev/xvda
    n2ws
  12. Identify the stopped instance from the list and attach it as the root device. (It is very important to identify the root device drive and only attach the new volume as the root device.)
    n2ws
  13. Start the instance after the new root volume is attached.
    n2ws

    Using CLI:
    ec2-start-instances i-bc781c50
    n2ws
  14. Log into the instance console using PuTTY or an SSH client. (Note: This time, the public DNS will be different since the instance was first stopped and then started. If you want to keep the same public DNS, use an elastic IP.) If this is not your root volume and you are attaching the volume as an additional volume to a Linux instance, you should run the command “resize2fs ” to increase the size of the new volume. As for the root volume, AWS will automatically increase the file system according to the updated size.
    n2ws

  15. Run the command “df –h” again to check the size of the root device.
    n2ws

    The above mentioned command displays that the size of the root device is now 30GB.
    Note: In the steps above, the root volume size was increased from 8GB to 30GB. However, you can follow the same steps to increase the size of any additional attached volume to a running instance.
    As you can see, snapshots provide a very handy option to back up data at a specific point in time while achieving HA and DR, as well. With this ability, we were able to change the size of the EBS volume shown above. N2Ws offers Cloud Protection Manager (CPM), which is an enterprise-class backup/recovery and disaster recovery solution for EC2. It is a software product that uses EBS volumes and RDS databases to automatically take snapshots at regular intervals. Additionally, you can set up policies and schedule backups for various targets.

Comments

Popular Posts

How to pass hash in Postman

nginx: unrecognized service

Bootstrap Select Picker append add new item if search not exist

Reading Excel Sheets using "Roo" gem in ruby on rails

Add CORS to Nginx on AWS Elastic Beanstalk

Enable gzip compression on Elastic Beanstalk with nginx

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Get video duration by URL in Ruby on Rails

site-enables nginx setting in ruby in rails