About this blog

'Going Spatial' is my personal blog, the views on this site are entirely my own and should in no way be attributed to anyone else or as the opinion of any organisation.

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.

  1. 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.
  2. Backup your instance to an AMI. One can't be too careful - who said we are paranoid?
  3. 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.
  4. 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. 
  5. 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. 
  6. With the new volume created, detach the old volume from the instance. Do this in the same VOLUMES page on the dashboard. 
  7. Attach the new volume to the instance. Use the same device name that you saved in step 3 - you did write this down right?  
  8. With the new, larger volume attached to your instance. Restart your instance.
  9. 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.

Done. You should have a new volume now and more space to fill.

Enjoy.

No comments:

Post a comment