Expanding the Size of your EBS Volume on AWS EC2 for Linux
Resizing your EBS Volume on the fly, that is attached to your EC2 Linux instance, on Amazon Web Services.
We want to resize our EBS Volume from 100GB to 1000GB and at the moment my EBS Volume is 100GB, as you can see:
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.9G 60K 7.9G 1% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
/dev/xvda1 99G 32G 67G 32% /
Now we want to resize the volume to 1000GB, without shutting down our EC2 instance.
Go to your EC2 Management Console, Select your EC2 Instance, scroll down to the EBS Volume, click on it and click the EBS Volume ID, from there select Actions, modify and resize the disk to the needed size. As you can see the disk is now 1000GB:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 1000G 0 disk
xvda1 202:1 0 1000G 0 part /
But our partition is still 100GB:
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.9G 60K 7.9G 1% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
/dev/xvda1 99G 32G 67G 32% /
We need to use growpart
and resize2fs
to resize our partition:
$ sudo growpart /dev/xvda 1
CHANGED: disk=/dev/xvda partition=1: start=4096 old: size=209711070,end=209715166 new: size=2097147870,end=2097151966
$ sudo resize2fs /dev/xvda1
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 63
The filesystem on /dev/xvda1 is now 262143483 (4k) blocks long.
Now we will have a resized partition to 100GB:
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.9G 60K 7.9G 1% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
/dev/xvda1 985G 33G 952G 4% /
Resources: