Extending the disk space on Linux Server (AWS)

You can extend the disk space online on your AWS Linux VM.

Note down your EC2 instance ID and the block name you want to extend.

instance ID

User@dbhost:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde  300G 17G  283G 6% /Shared

Goto Volumes under your EC2 and search by your Instance ID. This will list all your volumes that are attached to this EC2 instance.

goto volumes

It is recommended to make a snapshot of the volume before extending the size of the volume.

Search the volumes by EC2 instance names

search volumes attached

Modify the volume. The size here indicates the total size of the volume and not the volume to be added.

modify volume

modify volume2

Once you modify the instance the state of volume becomes “In Use – Optimizing”.             To complete it might take quite some time based on the size. Wait until the volume becomes green again.

in usa

Now your disk volume is ready for extension on Operating System level.

Before extending find the type of file system :

dbhost:~ # lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
hda
`-hda1 ext4 ROOT  /
xvdb LVM2_member 
|-vggroup-lvdata xfs 

Find also the full path of the volume:

dbhost:~ # fdisk -l

Disk /dev/xvde: 300 GiB, 322122547200 bytes, 629145600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/vggroup-lvdata: 128 GiB, 137443147776 bytes, 268443648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes

Extend the disk space using one of the the below commands based on your file system type:

dbhost:~resize2fs <Volume_Name>    #For ext4 file systems

dbhost:~xfs_growfs <Volume_Name>   #For xfs file systems

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s