Saturday, January 31, 2015

increase disk size on EC2

Our websites run on a large reserved instance of Windows Server 2008 R2 on Amazon’s EC2 infrastructure. It’s worked out really well, but today I noticed that we were getting close to our default 30GB disk space limit. I cleaned out some old logs that were hanging around, but our sites have grown so they’re simply taking up more space.
I knew adding disk space to an EC2 instance wasn’t going to be exactly straightforward and came across this forum thread with other people talking about their experiences. Someone in that thread talked about creating a new volume, attaching it, then expanding the C: drive on the Windows Server, so I went down that path and documented the process.
NOTE: This isn’t a precise walkthrough with hundreds of screenshots and a true step-by-step process. I’m assuming you’re already familiar with EC2, how to manage it, and the terms and language involved.

1. Create Snapshot of Current Volume

The first thing you need to do is create a new snapshot of the volume currently being used. This will ensure you can pick up exactly where you left off once the drive is expanded.

2. Make Note of the Snapshot ID

Once the snapshot is created, write down the snapshot ID somewhere. You’ll need to know it for the next step.

3. Create New Volume

Now that you have a snapshot of your current volume, you need to create the new volume that you will use. They keys in this step are to 1) enter a larger size than you already have and 2) to make the new volume use the snapshot you just created for the current volume, as shown below:
Creating a new EC2 volume

4. Stop Your Instance

Once that’s done, you need to stop your EC2 instance. Yes, you’ll have a little downtime, but not much. Make note of the new volume ID.

5. Attach the New Volume to Your Instance

Now what you want to do is attach the new volume to your EC2 instance. Select your stopped instance from the dropdown list, and be sure to enter /dev/sda1 as the Device. This will ensure the new volume is used as the boot drive for the instance, as shown below:
Attaching an EC2 volume
Hat tip to this ServerFault thread about using /dev/sda1 as the device for the boot drive.

6. Restart Your Instance

With your new volume attached, start your EC2 instance back up. This will take a few minutes and when completed you should see the instance and volume be associated to each other. Also, stopping and restarting the instance will most likely cause the instance to get a new public IP address.

7. Update Your DNS Entries

Because the instance will be given a new IP address, you’ll need to update all DNS entries for any domain that points to it. This wasn’t obvious from any of the forum threads I found, so I want to be sure to call it out.

8. Extend Your Server’s C: Drive

Once the EC2 instance is back online and the DNS changes have taken effect, login to your server and follow these steps:
  • Go to Administrative Tools > Computer Management.
  • Under Storage, to go Disk Management.
  • You should see the C: drive and the remaining chunk of unallocated space.
  • Right-click on the C: drive and select Extend Volume. Follow the wizard until done.
Open Windows Explorer and verify the C: drive is now bigger than before:
Bigger hard drive

That’s It

Like I said, this isn’t entirely straightforward to do, but it’s not all that painful either. Our total downtime was around 20 minutes, with a good part of that me being extra cautious and documenting the process.
Hopefully this little tutorial comes in handy for other people needing to increase the disk space on their EC2 instance

No comments:

Post a Comment