Launch an AWS EC2 AMI instance with an EBS disk larger than the default

When you launch an EBS instance on EC2, you get a root disk size that is the same as what the machine image was created with.  For example, the Ubuntu AMIs by default are 8GB.  Typically, the best approach is to leave the root volume this size and add additional volumes provisioned with the size needed for particular data (mysql data files or whatever).

However, sometimes, you just need a bigger root disk than 8GB.  It IS possible to launch such an instance.  Use this command:

# Launch an instance with a specific root disk size instead of the default
# New volume size in GB
SNAPSHOT_ID=`ec2-describe-images $UBUNTU_EBS_IMAGE | egrep "^BLOCKDEVICEMAPPING" | cut -f4`
ec2-run-instances $UBUNTU_EBS_IMAGE  # Don't forget all your other normal parameters
  --block-device-mapping "/dev/sda1=$SNAPSHOT_ID:$VOLUME_SIZE:true:standard"
# Ubuntu images on boot will auto-resize their root disk to match the available EBS size

Leave a Reply

Your email address will not be published. Required fields are marked *