|
/Hosting/Amazon/EC2:
Increase EBS Root Volume Size of an EC2 Server (Complicated)
Complicated because this is a RightScale image with multiple partitions, so resize2fs did not work the first time per[1].
Pick the image you want to resize (this one has an 8G root volume):
$ ec2-describe-images ami-e00df089 IMAGE ami-e00df089 944964708905/rightimage_debian_6.0.1_amd64_20110406.1_ebs 944964708905 available public x86_64 machine aki-4e7d9527 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda snap-b62f31da 8
Start a server up with a 25G volume instead:
$ ec2-run-instances -t t1.micro --key clayton --block-device-mapping /dev/sda=:25 ami-e00df089
Log in and see (in part):
# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda2 5.0G 1.2G 3.6G 24% /
Here is where things get funky, as "resize2fs /dev/xvda2" will not work per [1] because there are two other partitions: xvda1 is /boot and xvda3 is swap. [2] to the rescue. Hoping that it is the swap partition that is in the way, I got rid of it and rebuilt the partition table as follows: deleting partitions 2 and 3, creating a new partition 2 (accepting the defaults) and then writing the new partition to disk(w):
# fdisk /dev/xvda d 2 d 3 n p 2 w
Do not forget to remove the swap line from /etc/fstab, and reboot. Now:
# resize2fs /dev/xvda2
works! And all is well. Now, as we have done before, create a new image to save our work:
ec2-create-snapshot vol-e41af089
SNAPSHOT snap-697ad00b vol-e41af089 pending
Once the snapshot is finished:
ec2-register -a x86_64 -b '/dev/sda=snap-697ad00b:25:false' -n 'Squeeze_64' -d '64 bit Squeeze' --kernel="aki-4e7d9527"
[1] http://alestic.com/2009/12/ec2-ebs-boot-resize
[2] http://bioteam.net/2010/07/how-to-resize-an-amazon-ec2-ami-when-boot-disk-is-on-ebs/
posted at: 05:10 | path: /Hosting/Amazon/EC2 | permanent link to this entry