How to expande the Storage Space of an Amazon EC2 Volume

Sometimes, it is necessary for you to increase the storage space of an existing volume without losing the data that is on the volume. This topic explains how to expand the storage space of an Amazon EBS volume by migrating your data to a larger volume, and then extending the file system on the volume to recognize the newly-available space. After you verify that your new volume is working properly, you may delete the old volume.

  • Stop the instance
  • Create a snapshot of the volume to expand.
    • In the navigation pane, click Volumes, right-click on the volume to be expanded, and select Create Snapshot.
    • Enter a Name and Description for the snapshot, and click Yes, Create.
  • Create a new volume from the snapshot.
    • In the navigation pane, click Snapshots.
    • When the status of the snapshot that you just created is set to completed, select the snapshot and click Create Volume.
    • It can take several minutes for the snapshot to complete.
    • In the Create Volume dialog box, select the desired volume type, enter the new size for the volume, set the Availability Zone to the same Availability Zone as the instance, and click Yes, Create.
  • Detach the old volume.
    • In the navigation pane, click Volumes, select the old volume from the list of volumes, and make note of the value of device name in Attachment Information. The attachment information value takes the following form:
instance information:device name
    • Right-click the old volume and select Detach Volume.
    • In the Detach Volume dialog box, click Yes, Detach. It may take several minutes for the volume to be detached.
  • Attach the newly expanded volume
    • In the navigation pane, click Volumes, select the new volume from the list of volumes, right-click the new volume, and select Attach Volume.
    • Select the instance from the Instances list, enter the same device name, and click Yes, Attach.
  • Restart the instance.
    • In the navigation pane, click Instances, right-click the instance, and select Start.
    • In the Start Instances dialog box, select Yes, Start. If the instance fails to start, and the volume being expanded is a root volume, verify that you attached the expanded volume using the same device name as the original volume (root volumes must be attached as /dev/sda1).
    • Only EC2-VPC instances with Elastic IP addresses retain their public IP address when they are stopped. If your instance is running in EC2-Classic, the EIP address is disassociated when the instance is stopped, and you must re-associate the EIP after restarting the instance. If your instance is not using an EIP, then you need to retrieve your new public DNS name for your instance from the Instances page of the Amazon EC2 console to connect to it.
After the instance has started, you can check the file system size to see if your instance recognizes the larger volume space. On Linux, use the df -h command to check the file system size.

[ec2-user ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G  943M  6.9G  12% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm

You may need to

How to extend a Linux file system


Popular posts from this blog

Check MySQL query history from command line