07/07/2015 Wannes Van Causbroeck

Extend ec2 boot disk

As most aws users know by now, amazon doesn’t make it particularly easy to extend boot volumes. The centos images don’t use LVM and the EBS stores are not extendable.
The aws recommended way of extending a disk is:

  • stop the instance
  • unmap the volume
  • create a snapshot of the volume
  • create a bigger volume of the snapshot
  • mount the new volume on another stopped instance (in the same AZ! Otherwise we can’t map the volume)
  • start that instance
  • delete and recreate the partition table to fit to the size of the disk + resize the filesystem
  • (the two above steps are needed when using parted. Fdisk can handle modifying the root volume in situ, but i couldn’t get it to play nice through scripting

  • stop the instance
  • move the volume to the original instance
  • start that instance

pfew! To avoid doing this manually and getting bored to death I wrote a small script to handle this for me. It’s not the cleanest and most flexible script in the world (end could be improved no end), but it gets the job done.

Leave a Reply

Your email address will not be published. Required fields are marked *