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).

Related posts:

  1. Simple way to create Amazon EC2 AMI from running instance
  2. Shell script: Terminate an Amazon EC2 instance
  3. Detect read-only partition in Linux
  4. Setup Amazon EC2 API tools on Macbook
  5. Backup disk partition tables
Tags: , , ,


Joseph chen is a system administrator from south China. He has a keen interest in Open Source and system administration solutions.

2 Responses to “Resize root partition for a running EBS EC2 Instance”

  1. Eric Hammond says:

    I’ve listed the commands necessary for each step in this article I wrote almost two years ago:

    http://alestic.com/2010/02/ec2-resize-running-ebs-root

    – Eric Hammond

  2. joseph says:

    Welcome Eric! Your website makes a lot of sense, thank you!

Leave a Reply

© 2006-2011 Admon Home. All rights reserved.