My tweets on GIS, Humanitarian, Tech, Games and Randomness

Friday, 29 August 2014

Growing EBS Volumes

Been using AWS for a while but some simple things never came across my desk until quite recently: the need to expand the size of the C drive on my Windows images. Ordinarily, an on-premise server would have it shut down, the C drive removed, cloned, replaced and restarted. Or start off with a bigger-than-necessary hard drive.

Anyway, the principle of removing, cloning and replacing a volume in AWS is very similar to the physical process; without the need to whip out a screwdriver.

Like a live running machine, it is not possible to change the size of an existing EBS volume when it is running. Best to shut it down. Interestingly, I have found it is not possible to resize an EBS volume to something smaller, in an effort to save cost. Any EBS volumes created from snapshots must be at least as big as the original snapshot size.

Here are the steps I took to expand the volume.

Stop the instance that has the EBS volume you need to expand. This will ensure that all data has completely been written to the volume.

Backup your instance to an AMI. One can't be too careful - who said we are paranoid?

Record the device that the volume is attached to your instance. For example, /dev/sda1. This information is available in the AWS Management Console, on the volumes page, under the "Attachment Information" column.

Create a snapshot of the volume and wait for the snapshot to complete. This could take anywhere from five minutes up to a few hours.

Now create a new volume based on your snapshot that was just created in step 4. Specify a new ( and larger) size for the volume. Wait for the new volume's status to be "available". Again, this should only take a few minutes but be patient. I find the AWS CLI gives a more accurate view than the dashboard.

With the new volume created, detach the old volume from the instance. Do this in the same VOLUMES page on the dashboard.

Attach the new volume to the instance. Use the same device name that you saved in step 3 - you did write this down right?

Connect......and voila, you can login, but wait, you should notice that the operating system still thinks the volume is the original size! What is going on? You need to 'tell' the operating system to expand the existing partition to use the new space you just created.

Now to Resize the Partition

If you are using Windows, you can use the Disk Manager to expand the size of the existing partition to include the new unallocated space. Go to 'Computer Management' and select the 'disk management' option. Select the disk (C drive) and you will see that the extra space is there on the disk; but just unallocated. Right click and 'extend'.

For all you Linux-heads, there is the ever reliable 'resize2fs' command.

Once you have confirmed that your instance is running correctly using the new volume, you can delete the old volume to save and money.

Followers

About Me

My ideal job would be: to work for a humanitarian organisation, saving the world, one person at a time; write short sci-fi stories; that make it into book form and play loads of online-games and be acknowledged as a guru. Oh, I would love to travel as much as possible too and take loads of photos. I actually do the above four things but all for next to no-pay.

So in order to maintain a meaningful existence, I work at a world leading software company in GIS and work with all things cloud and *everything*-as-a-service. I run, manage and motivate a small team of highly skilled professionals in the murky world of DevOps delivering services, data and cool stuff to people. At least, that is what I think it is called and that's what we should be doing.