So in my previous post I talked about all this work to make an EBS backed AMI. At the end though I realized that I didn’t size the server right. Doh! This was fairly stupid of me. So I followed the same set of steps because all the instructions I found on resizing an existing image didn’t seem to work. And then I tried something, you know, for $#!*$ and giggles. Imagined how annoyed I was when it worked.
So here is the command for registering an EBS backed image based on a particular snapshot:
ec2-register --block-device-mapping /dev/sda1=s<snapshot id>::false --name "<ami name>" --kernel <kernel id> --ramdisk <ramdisk id> -K <key file> -C <cert file>
(Note: If you want the volume to persist after termination then you’ll want to change the true in the –block-device-mapping flag to false)
So the key is in the –block-device-mapping flag. The documentation for Amazon states:
So it says somewhere in there that you can specify the size of the AMI in that particular flag, so if I want to increase the size of the instance all I would need to do is change the flag to read:
--block-device-mapping /dev/sda1=s<snapshot id>:50:true
or whatever size you want. Afterwards you’ll need to log on to the server and resize the drive. You can do this by running the following (assuming you’re using an ext3 root file system, which is what I used in my previous post):
sudo resize2fs /dev/sda1
it’ll resize the drive and you should be good to go.