Home Linux Extend the size of EBS volume in your EC2 instance

Extend the size of EBS volume in your EC2 instance

0
Extend the size of EBS volume in your EC2 instance

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.

Create Snapshot

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.

Extend the size of EBS volume in your EC2 instance
Create Snapshot

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.

#df -h
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
that sufficient.

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.

Step-1
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
image -1

Increase Volume

We used Volume type – General Purpose SSD(gp2)
Next follow the on-screen command to finish, We have successfully added the volume.

Step-2
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.

 

Reference: https://aws.amazon.com/premiumsupport/knowledge-center/extend-linux-file-system/

You may also like:
How to install IIS Web Server on Amazon EC2 Instance (Windows Server 2008)

How to install nginx, mysql, phpmyadmin, php in Ubuntu

VPN Connection issue in Windows 10

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exit mobile version