Resize root partition for a running EBS EC2 Instance

As long as you are all right with a little downtime of the EC2 instance (in a few minutes), it is possible to extend the root partition on a running EBS boot EC2 instance, without needing to start a new instance.

Before starting playing the trick, you need to have Amzon EC2 API tools installed.

Then the steps are:

  1. Shutdown the instance and detach the volume.
  2. Build a snapshot for the detached volume and create a volume with a larger size based on the snapshot.
  3. Attach the new volume to the instance and start it.
  4. Login the instance and resize the root file system to fill the new EBS volume.

Commands for the last step are listed as below:

# ext3 root file system (more common):
sudo resize2fs /dev/sda1

# XFS root file system (less common):
sudo xfs_growfs /

xfs_growfs is supplied by xfsprogs, which can be installed via yum (or apt-get).

Share Button

2 thoughts on “Resize root partition for a running EBS EC2 Instance

Leave a comment

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