This one is pretty straightforward, but it is a nice little one that I might have to come back to at some point.  There is a really simple workflow for this:

1. Shutdown the EC2 instance

2. Create a snapshot of the volume that you want to expand

3. Create a new volume from the snapshot you just created – this is the part where you make the volume bigger

4. Un-attach the the existing volume from the instance and attach the new volume that you just created

5. Startup the EC2 instance

6. run

 

Of course there is a lot more that can be done and explained, and that is below.

PREREQUISITE MENTIONS –

First, not all operating systems allow you to resize the volume that the OS is installed on.  If you are intending on resizing your OS volume, I would recommend you first verify it is a supported function on your OS.  Quick reference, OS volume extending was only available in Windows on Server 2008 or Vista and later and is spotty for Linux distress (as far as I know).

Second I REALLY recommend that you identify what your volume is mounted as within the OS; in Linux you can run df -h and in windows you can either look in Computer Management or just open Windows Explorer to check the drive letter.  If (for some reason) when you attach your new volume it attaches under a different mount point, you could be in a pickle if you don’t know what the volume was attached at.  THIS DOES NOT DIRECTLY CORRELATE WITH WHAT IS LISTED AS THE MOUNT POINT/DEVICE WITHIN THE EC2 CONSOLE.

1. Shutdown the EC2 instance – Not much to explain on this one. Shut it down. This is to ensure that the volume is in a consistent state.

2. Create a snapshot of the volume that you want to expand – The way that you clone a volume on Amazon EC2 is to create a snapshot and then create a disk from the snapshot.  This is available by right-clicking the volume that you want to extend and click Create Snapshot.  Be sure to name the snapshot descriptively because the name (and description) is the only way to identify it once you get to the snapshot list. (Volume list is available by clicking Volumes in the left pane. The instance that it is connected to and the disk identifier will be listed in the farthest right pane of the volume list)

3. Create a new volume from the snapshot you just created – Building off of step 2, we need to complete the process by creating a volume from the snapshot.  Find your newly created snapshot in the snapshot list, right-click and Create volume from snapshot.  At this point you have the ability to specify your size and your availability zone.  NOTE: You must make sure that you create this volume in the same availability zone as the disk you created the snapshot from/where your instance exists. (Snapshot list is available by clicking Snapshots in the left pane)

4. Un-attach the existing volume and attach the new volume that you just created – Locate the disk that you are resizing/replacing and note what it is mounted as on the server by looking in the right pane (e.g. /dev/sda1, /dev/sdf, etc.), then right-click the disk and click Detach Volume.  Now attach your newly created disk by right-clicking it and clicking Attach Volume, then select the instance you would like to attach it to and make sure that what is listed as the Device matches what you noted earlier in this step. (e.g. /dev/sda1, /dev/sdv, etc.)

5. Startup the EC2 instance – Again, not much to explain.  Start it up.

6. Run sudo resize2fs <mount point> – After your instance starts up, it shouldn’t notice any difference with the new volume, the structure is identical, etc. The problem is that we need to resize the partition to extend to the whole volume, since that does not resize with the volume.  To identify what your volume is mounted at (mount point) you can run df -h and it will list all of your volumes and their mount points. As noted in the prerequisites, some operating systems don’t allow you to expand the operating system volume, in which case the workaround is to attach it to another machine as a secondary (non-os) volume (between steps 3 and 4) and extend it, then un-attach and move forward with step 4.

NOTE: The command above is (obviously) the command in linux.  To do this in Windows, you can open Disk Utility in Computer Management, right click the volume and click extend.  This was not available in Windows pre-Server 2008, for that you can utilize the diskutil command.

 

Sites I used when writing this:

http://cloud.tekgoblin.com/2012/08/27/aws-guides-how-to-resize-a-ec2-windows-ebs-volume/

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html

http://hexeract.wordpress.com/2012/04/30/how-to-expand-the-root-filesystem-of-a-11-10-ubuntu-running-inside-vmware-player/

 

0.00 avg. rating (0% score) - 0 votes
Tagged with →