Sunday, March 11, 2018

Increasing volume size on EC2 Server

Increasing volume size or disk size on ec2 instance is as follows.

1) Log in to aws access contol system and select services > EC2 from the menu.

2) Under Elastic Block Storage click on the volume.

3) Select the volume which is to be increased. right click and click on modify volume.

4) Enter new size in GB for the volume and click save. Volume size will be increased.

5) Now you need to extend partition to the unused space. Login to your ec2 server using putty or other terminal tool.

6) Use the df -h command to report the existing disk space usage on the file system.  you will see output as below.
                     
              [ec2-user ~]$ df -h
             Filesystem            Size  Used Avail Use% Mounted on
            /dev/xvda1            8.0G  943M  6.9G  12% /
            tmpfs                 1.9G     0  1.9G   0% /dev/shm
            /dev/xvdf            1014M   33M  982M   4% /mnt


7) Expand the modified partition using growpart (and note the unusual syntax of separating the device name from the partition number):
        
           sudo growpart /dev/xvda 1
where xvdf is the disk and 1 is parition number.

you will get following output.
     
                        $sudo growpart /dev/xvdf 1
CHANGED: disk=/dev/xvdf partition=1: start=4096 old: size=16773086,end=16777182 
new: size=73396190,end=73400286

You can see old size has been modified to the new size.

8) Use a file system-specific command to resize each file system to the new volume
capacity.
For a Linux ext2, ext3, or ext4 file system, use the following command, substituting the device name to extend:  

you will get following output.

[ec2-user ~]$ sudo resize2fs /dev/xvda1
resize2fs 1.42.3 (14-May-2012)
old_desc_blocks = 1, new_desc_blocks = 3 

9)  Use the df -h command to report the existing disk space usage on the file system.  you will see output as below.

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             70G  951M   69G   2% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/xvdf             100G   45M  100G   1% /mnt

Congratulation ! increaded volume size has been reflected to ec2 instance.                      




No comments: