The best-practice way to create EC2 instances with EBS volumes that will soon need to be very large

amazon ec2amazon-ebs

When launching EC2 instances, it seems most community AMI's come with a 8gb EBS volume attached as the root drive. We will definitely need larger than 8GB as our database size grows. What is the advisable way to design our system? The options I see are:

  1. Use the 8GB storage until we need to expand, and then follow one of several lengthy online tutorials to expand the size of the root drive.

  2. Attach a 2nd EBS volume to the instance that is larger (e.g. 60 GB) and store all data on this volume. If I want to use MongoDB or MySQL as a database, will it be easy to install the database application files on the root volume but store the data on another volume?

What is the best-practice solution?

Best Answer

Unless you're using an EBS-backed EC2 instance the AMI image is extracted to a 10GB drive image that is recreated when the instance is started. I use instance-stored EC2 instances instead of EBS-backed ones for all my server instances. I then simply make the EBS volumes whatever side I need and mount them as secondary drives.

With the EBS volumes I found that using the xfs filesystem and simply using the entire EBS volume without any partitioning was the best course of action. To increase the volume when it was necessary I would perform a snapshot of the existing EBS volume and then create a new larger volume built from the snapshot. You then simply detach the existing EBS volume and attach the new one. Once the new volume is mounted it will show as the current volume size until you run the xfs expand utility command that has to be ran while the filesystem is live. Checking the capacity after that is done will show the new larger size.

Now if you're using an Ubuntu AMI you can install the ebsmount package and create a hidden directory on the EBS volume and configure the system to actually automount using udev when the EBS volume is attached to the EC2 instance.

Related Topic