Welcome to the DjaoDjin Blog!

A place to share experiences in building Software-as-a-Service.

Resizing an EBS disk

by Sebastien Mirolo on Fri, 21 Oct 2016

Sometimes you underestimated the disk size required to setup and run a service on AWS. The quickest way to keep moving forward is to resize the EBS storage associated with the EC2 instance.

Amazon's instructions to expand an EBS volume through the AWS console are straightforward. Here the steps from the command line.

We will first need to take note of the instance_id, availability_zone volume_id, and device_id.

$ aws ec2 describe-instances --instance-ids *instance-id*
"Placement": {
    "AvailabilityZone": "*availability_zone*"
"BlockDeviceMappings": [{
    "DeviceName": "/dev/sda1",
    "Ebs": {
        "VolumeId": "*volume_id*",


With the required information noted, we are ready to go. Let's stop the instance first.

$ aws ec2 stop-instances --instance-ids *instance-id*

We then create a snapshot of the current volume.

$ aws ec2 create-snapshot --volume-id *volume-id*
    "SnapshotId": "*snap-id*",

We can now create a new volume from the snapshot, setting it to the desired size. Note that we must make sure the availability zone of the volume matches the availability zone of the EC2 instance otherwise we won't be able to associated the volume to the instance.

$ aws ec2 create-volume --size 32 --availability-zone *zone-id* --snapshot-id *snap-id*
    "VolumeId": "*new-volume-id*",
$ aws ec2 detach-volume --volume-id *volume-id*
$ aws ec2 attach-volume --instance-id *instance-id* --device /dev/sda1 --volume-id *new-volume-id*

It is time to restart the instance.

$ aws ec2 start-instances --instance-ids *instance-id*

We can check that the new volume size is reflected so we don't need to extend the Linux File System in our case.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       32G  8.8G   22G  29% /

A bit of clean up: we delete the previous volume and snapshot.

$ aws ec2 delete-volume --volume-id *volume-id*
$ aws ec2 delete-snapshot --snapshot-id *snap-id*

More to read

If you are looking for more AWS related posts, you might be interested to read PostgreSQL, encrypted EBS volume and Key Management Service and Deploying on EC2 with Ansible.

More technical posts are also available on the DjaoDjin blog, as well as business lessons we learned running a subscription hosting platform.