Monday, October 3, 2011

Increase EBS Image Size

Increase EBS Image Size

Scenario : Lets say you wanted to make your own image based on the stock Amazon AMI. But after you are done with the painful customization , you realize you started of with a EBS size of 6GB !
You need more than that !

You would have 2 options now :
1. Restart with a bigger size AMI. (Good luck and have fun again.)
2. Resize the current one to a bigger size.

This post is about the second option.

Assuming your current instance name is INST1, the attached volume is VOL1SMALL.
It can be an easy task if you follow the steps shown below :

1. Stop the instance. (I have noticed the steps below complete a lot faster if the instance is stopped)
2. Create a snapshot of the attached volume . Let it be SNAP1.
3. Now create a new volume from the snapshot you just created. Let this be VOL2BIG (Choose your higher size while doing this )
4. Select the already attached volume, i.e. VOL1SMALL and notice the path where it is mounted. It should be most probably /dev/sda1 . Now Detach this volume.
5. Now right click on the newly created volume VOL2BIG and set the mount path to be the same "/dev/sda1".
6. Start the instance again. INST1.
7. Do the df -h and you'll STILL SEE 6GB ! What the Hell !! Don't panic :-)

All you gotta do is resize the partition. To do that :

1. run "fdisk -l"
Note the device name of the newly attached volume. In my case it was "/dev/xvde1"

2. run "resize2fs /dev/xvde1 SIZE"

Note SIZE should include the units as well. If you want it to grow to 15Gigs .. use 15G
Do man resize2fs for more details.

Thats it ... Running df -h will now show you the new size !

Enjoy !

No comments:

Post a Comment