How to resize AWS ec2 ebs root partition without rebooting in 3 steps

Go to the AWS EBS dashboard and modify the volume size. Might be good to create a snapshot of it for safety but haven’t really failed ever doing this.

# 1. Check the device of your partition
$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 28.1M 1 loop /snap/amazon-ssm-agent/2012
loop1 7:1 0 97M 1 loop /snap/core/9665
loop2 7:2 0 55M 1 loop /snap/core18/1880
loop3 7:3 0 71.3M 1 loop /snap/lxd/16100
xvda 202:0 0 25G 0 disk
└─xvda1 202:1 0 20G 0 part /
xvdf 202:80 0 1T 0 disk /mnt/ebs/frostwire-files
xvdg 202:96 0 16G 0 disk /mnt/ebs/oldroot

# 2. Grow the partition
$ sudo growpart /dev/xvda 1
CHANGED: partition=1 start=2048 old: size=41940959 end=41943007 new: size=52426719 end=52428767

# 3. Extend the file system
$ sudo resize2fs /dev/xvda1
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 4
...

# Done, new size is reflected with df
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 25G 19G 5.6G 78% /

Leave a Reply

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