Created EC2 instances default to 8GB of storage. It's possible to configure this to a larger size at the time of instance creation, but I often find myself needing to adjust the storage of an already-running instance. It's painless, I can just never remember the sequence of commands.
- Resize EC2 storage in AWS console (EC2 → EBS →
Modify Volume) $ sudo growpart /dev/xvda1 1$ sudo sudo resize2fs /dev/xvda1
NB: the name of your drive/partition might be different to /dev/xvda depending on your instance type
(e.g. for one my accelerated computing machines the relevant drive is /dev/nvme0n1). In any case,
the following sequence of steps is identical.
- Resize EC2 instance's EBS Volume
- Go to your EC2 dashboard and select the instance whose storage you want to change
- Click on
Storageand then select theVolume IDof the Volume you want to change - While the appropriate row Volume row is selected, click on the
Actionsdropdown and selectModify Volume - Change the storage size & apply the changes
- Resize the OS partition of your instance
- Run
$ df -hto show the current size of the partition (should see that/dev/rootor/dev/xvdapartition is still only 8GB). - Run
$ lsblkto see the EBS volume specifics. Here we should see that/dev/xvdahas the new size set in the AWS console, but that it's child partition/dev/xvda1(you root drive) only has 8GB. - Run
$ sudo growpart /dev/xvda 1to resize the partition to fill its parent - Rerun
$ lsblkto make sure your partition is now the intended size.
- Run
- Resize the filesystem
- If you run
$ df -hagain, you'll see that despite sizing the partitions correctly, the filesystem is still showing 8GB. You need to resize this to fill the newly modified partition. - Run
$ sudo resize2fs /dev/xvda1, and recheck to$ df -hto make sure you changes were applied.
- If you run
Voilà! 🍰