Resize AWS EC2 Volume
In this excerise, we will try to resize a volume for EC2
- Size(any type) and IOPS(Some types) can be increased for the EBS volumes
- Repartition required after resizing
- The volume is still usable after increasing the size
- Can’t decrease the EBS volume size
Check volume before the resize
[root@ip-111-111-111-111 ec2-user]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 8G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part
[root@ip-111-111-111-111 ec2-user]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 477M 0 477M 0% /dev/shm
tmpfs 191M 2.8M 188M 2% /run
/dev/xvda1 8.0G 1.6G 6.4G 20% /
tmpfs 477M 0 477M 0% /tmp
tmpfs 96M 0 96M 0% /run/user/1000
Resize the volume
- Go to EC2->Elastic Block Store -> Volumes
- Select the volume to be resized
- Go to Actions->Modify volume
- Change the Size to the one we need, for example from 8GB to 10GB here
- Check the volume
[root@ip-111-111-111-111 ec2-user]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 8G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part
[root@ip-111-111-111-111 ec2-user]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 477M 0 477M 0% /dev/shm
tmpfs 191M 2.8M 188M 2% /run
/dev/xvda1 8.0G 1.6G 6.4G 20% /
tmpfs 477M 0 477M 0% /tmp
tmpfs 96M 0 96M 0% /run/user/1000
Extend the partition and reboot
[root@ip-111-111-111-111 ec2-user]# growpart /dev/xvda 1
CHANGED: partition=1 start=24576 old: size=16752607 end=16777183 new: size=20946911 end=20971487
[root@ip-111-111-111-111 ec2-user]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 10G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part
[root@ip-111-111-111-111 ec2-user]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 477M 0 477M 0% /dev/shm
tmpfs 191M 2.8M 188M 2% /run
/dev/xvda1 8.0G 1.6G 6.4G 20% /
tmpfs 477M 0 477M 0% /tmp
tmpfs 96M 0 96M 0% /run/user/1000
[ec2-user@ip-111-111-111-111 ~]$ reboot
Confirm the volume resized
[ec2-user@ip-111-111-111-111 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 10G 0 part /
├─xvda127 259:0 0 1M 0 part
└─xvda128 259:1 0 10M 0 part
[ec2-user@ip-111-111-111-111 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 477M 0 477M 0% /dev/shm
tmpfs 191M 2.9M 188M 2% /run
/dev/xvda1 10G 1.6G 8.4G 16% /
tmpfs 477M 0 477M 0% /tmp
tmpfs 96M 0 96M 0% /run/user/1000