Unable to growpart because no space left
I came across this article http://www.daniloaz.com/en/partitioning-and-resizing-the-ebs-root-volume-of-an-aws-ec2-instance/ and solved it with ideas from there.
Steps taken:
- Note down root device (e.g. /dev/sda1)
- Stop instance
- Detach root EBS volume and then modify volume size if you haven't already
- Create an auxiliary instance (e.g. a
t2.micro
instance, or use an existing one if you wish) - Attach the volume from step 2 to the auxiliary instance (doesn't matter which device)
- In the auxiliary instance, run
lsblk
to ensure the volume has been mounted correctly sudo growpart /dev/xvdf 1
(or similar, to expand the partition)lsblk
to check that the partition has grown- Detach the volume
- Attach the volume to your original instance, with device set to the one you noted down in Step 1
- Start the instance and then SSH into it
- If you still get the message "Usage of /: 99.8% of X.XX GB", run
df -h
to check the size of your root volume partition (e.g./dev/xvda1
) - Run
sudo resize2fs /dev/xvda1
(or similar) to resize your partition - Run
df -h
to check that yourUse%
of/dev/xvda1
is no longer ~100%
For anyone that has this problem, here's a link to the answer: https://aws.amazon.com/premiumsupport/knowledge-center/ebs-volume-size-increase/
Summary
- Run
df -h
to verify your root partition is full (100%) - Run
lsblk
and thenlsblk -f
to get block device details sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp
sudo growpart /dev/DEVICE_ID PARTITION_NUMBER
lsblk
to verify partition has expandedsudo resize2fs /dev/DEVICE_IDPARTITION_NUMBER
- Run
df -h
to verify your resized disk sudo umount /tmp
Just make sure to clear tmp
folders before running the command growpart /dev/xvda 1
by running this other command sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp
that should do the trick.
Here is the full recap on resizing EBS volume:
Run df -h
to verify your disk is full (100%)
/dev/xvda1 8.0G 8.0G 20K 100% /
Run lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
`-xvda1 202:1 0 8G 0 part /
Clear tmp
folders a little bit
sudo mount -o size=10M,rw,nodev,nosuid -t tmpfs tmpfs /tmp
And finally increase space in the partition
sudo growpart /dev/xvda 1
CHANGED: partition=1 start=4096 old: size=16773087 end=16777183 new: size=41938911 end=41943007
And finally do a sudo reboot
wait for the instance to fully reload, ssh into the instance and run df -h
should show the new space added:
/dev/xvda1 20G 8.1G 12G 41% /
Notice the new available space, and see how it's not full anymore (not at 100%
now it's at 41%
)