Extend the size of EBS volume in your EC2 instance
Faced issue in accessing EC2 micro instance and to my surprise almost all space was consumed for
which I was getting error.
Before we proceed to extend the EBS volume in EC2 instance, for which we would not need any downtime for our instance.
For the safer side, let’s take a snapshot of the existing volume in any case something bad happens.
Open your EBS volume list from your EC2 Dashboard.
Right-click the volume.
Click Create Snapshot link.
Add the description value snapshot-backup-volume.
Add key : Name and value : snapshot-backup-volume.
Click button Create Snapshot.
It takes few minutes to complete. In between, you can sit back and relax.
Now we are safe to proceed with extending the volume.
As we can see the used space is 7.7GB out of 7.8GB, almost 100% space is being used.
Filesystem Size Used Avail Use%
/dev/xvda1 7.8G 7.7G 0M 100% /
We checked and cleaned some of the unwanted files and could merely make some space, which is not
du -hx –max-depth=1 / – Command to check folder wise space used.
Next option was to extend the storage volume and the steps as below.
Login to aws console, select the instance for which you need to extend the storage volume.
Select storage, select modify from the option, then type how much you want to extend as per the
We used Volume type – General Purpose SSD(gp2)
Next follow the on-screen command to finish, We have successfully added the volume.
Now login through ssh and run lsblk command.
#lsblk – To list out block devices. You will get output like below
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 25G 0 disk
└─xvda1 202:1 0 8G 0 part /
Extend the partition by typing sudo growpart /dev/xvda 1 ( Note that dev/xvda is the partition name and 1 is the partition number)
#sudo growpart /dev/xvda 1
Now extend the filesystem (If your filesystem is an ext2, ext3, or ext4 )
#sudo resize2fs /dev/xvda1
Now type df -ah command to check the primary storage volume has been extended.
You may also like:
How to install IIS Web Server on Amazon EC2 Instance (Windows Server 2008)