- Create snapshot for the disk
- Modify the volumn size in AWS GUI
- Check the previous disk usage, we are going to extend / from 8 GB to 50 GB
ubuntu@ip-172-31-4-112:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 475M 0 475M 0% /dev tmpfs 98M 2.0M 96M 2% /run /dev/xvda1 7.7G 7.1G 596M 93% / tmpfs 490M 0 490M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/loop0 56M 56M 0 100% /snap/core18/2066 /dev/loop1 33M 33M 0 100% /snap/snapd/12159 /dev/loop2 56M 56M 0 100% /snap/core18/2074 /dev/loop3 34M 34M 0 100% /snap/amazon-ssm-agent/3552 /dev/loop4 33M 33M 0 100% /snap/snapd/12398 tmpfs 98M 0 98M 0% /run/user/1000 tmpfs 10M 0 10M 0% /tmp ubuntu@ip-172-31-4-112:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 55.4M 1 loop /snap/core18/2066 loop1 7:1 0 32.3M 1 loop /snap/snapd/12159 loop2 7:2 0 55.5M 1 loop /snap/core18/2074 loop3 7:3 0 33.3M 1 loop /snap/amazon-ssm-agent/3552 loop4 7:4 0 32.3M 1 loop /snap/snapd/12398 xvda 202:0 0 50G 0 disk └─xvda1 202:1 0 8G 0 part /
- Use growpart command to extend disk space to partition
ubuntu@ip-172-31-4-112:~$ sudo growpart /dev/xvda 1 CHANGED: partition=1 start=2048 old: size=16775135 end=16777183 new: size=104855519,end=104857567 ubuntu@ip-172-31-4-112:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 55.4M 1 loop /snap/core18/2066 loop1 7:1 0 32.3M 1 loop /snap/snapd/12159 loop2 7:2 0 55.5M 1 loop /snap/core18/2074 loop3 7:3 0 33.3M 1 loop /snap/amazon-ssm-agent/3552 loop4 7:4 0 32.3M 1 loop /snap/snapd/12398 xvda 202:0 0 50G 0 disk └─xvda1 202:1 0 50G 0 part /
- Use resize2fs command to resize the new partition into ext4 format
ubuntu@ip-172-31-4-112:~$ sudo resize2fs /dev/xvda1 resize2fs 1.44.1 (24-Mar-2018) Filesystem at /dev/xvda1 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 7 The filesystem on /dev/xvda1 is now 13106939 (4k) blocks long.
- Result
ubuntu@ip-172-31-4-112:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 475M 0 475M 0% /dev tmpfs 98M 2.0M 96M 2% /run /dev/xvda1 49G 7.1G 42G 15% / tmpfs 490M 0 490M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/loop0 56M 56M 0 100% /snap/core18/2066 /dev/loop1 33M 33M 0 100% /snap/snapd/12159 /dev/loop2 56M 56M 0 100% /snap/core18/2074 /dev/loop3 34M 34M 0 100% /snap/amazon-ssm-agent/3552 /dev/loop4 33M 33M 0 100% /snap/snapd/12398 tmpfs 98M 0 98M 0% /run/user/1000 tmpfs 10M 0 10M 0% /tmp