In a previous article I described how to run an EBS boot AMI with a larger root disk size than the default. That’s fine if you know the size you want before running the instance, but what if you have an EC2 instance already running and you need to increase the size of its root disk without running a different instance?
As long as you are ok with a little down time on the EC2 instance (few minutes), it is possible to change out the root EBS volume with a larger copy, without needing to start a new instance.
Let’s walk through the steps on a sample Ubuntu 16.04 LTS Xenial HVM
instance. I tested this with ami-40d28157 but check for the latest
AMI ids.
On the instance we check the initial size of the root file system (8 GB):
$ df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 913M 6.5G 13% /