Resize Root Partition on boot from root on EBS EC2 instance

Written by NickWal

How to resize the root partition on an Amazon EC2 instance which has its root partition backed by Elastic Block Storage (EBS).

At the time of writing the documentation seems a little incomplete in this respect, so here is what I did to make a larger root partition on an Ubuntu Karmic Server EC2 instance.

  1. Stop the machine (do not terminate it)
  2. Take a snapshot
  3. When the snapshot has completed, restart the machine
  4. Create a new volume in the same availability zone as the current one, but with the new size
  5. Attach the new volume to the old machine using the amazon aws console (the device I used is /dev/sdd)
  6. e2fsck -f /dev/sdd
  7. resize2fs -f /dev/sdd
  8. e2fsck -f /dev/sdd
  9. Detach the volume
  10. Create a new shapshot
  11. Create a new AMI from the new snapshot

./ec2-register -K ~/ec2/pk-mypk.pem -C ~/ec2/cert-mycert.pem -n MyUniqueName -s snap-mysnap --kernel aki-5f15f636 --ramdisk ari-0915f660