Archive for March, 2012

Resize EBS volume on EC2

March 16th, 2012

This post will go through the steps required to resize an EBS volume that is attaches to an EC2 instance on Amazon Web Services using the AWS console

  • First stop the instance. Make sure you do not terminate, just stop and do not worry about the warning regarding ephemeral storage.
  • Note the mounting point where the volume is attached. Mine is /dev/SDA1
  • Detach the volume from the instance by clicking detach volume in the EBS section.
  • Create a snapshot of the volume. Depending on the size it could take an hour. In order to see the progress make sure you refresh the page by clicking the AWS consoles refresh button and not your browsers.
  • Create a volume from the snapshot specifying the size you require for the instance now.
  • Attach the new larger volume to the instance on SDA1
  • Start the instance
  • Reassign the elastic IP as this would have dropped off when the instance was stopped.
  • SSH to the instance and run the following
    df -h
    to ascertain the root partition code. Mine in this case is xvda1 and then run
    sudo resize2fs /dev/xvda1
    to resize the drive
  • Remove the old volume but keep the snapshot for backup.
  • Test that everything has worked as planned.

You have now increased the size of EBS volume attached to your EC2 instance on AWS. Feel free to comment.