linuxamazon-ec2hard-drive

Increase the root volume (Hard disk) of EC2 Linux running instance without restart - Step by step process


Problem:

I have EC2 instance with Linux (Ubunty) and root volume of 10 GB. I have consumed about 96% of the size and now my application responding slow, so I wanted to increase the size to 50 GB.

The most important point is, I have data already there and many applications are running on this EC2 instance and I don't want to disturb or stop them.

To check the current space available ~$ df -hT

enter image description here

Please use ~$ lsblk command to check the partition size


Solution

  • Here is the solution:

    1. Take a snapshot of your volume which contains valuable data.

    2. Increase the EBS volume using Elastic Volumes

    3. After increasing the size, extend the volume's file system manually.

    Details

    1. Snapshot Process (AWS Reference)

    1) Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.   
    
    2) Choose Snapshots under Elastic Block Store in the navigation pane.    
    
    3) Choose Create Snapshot.   
    
    4) For Select resource type, choose Volume.   
    
    5) For Volume, select the volume.
    
    6) (Optional) Enter a description for the snapshot.    
    
    7) (Optional) Choose Add Tag to add tags to your snapshot. For each tag, provide a tag key and a tag value.    
    
    8) Choose Create Snapshot.
    

    2) Increase the EBS volume using Elastic Volumes (AWS Reference)

    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

    2. Choose Volumes, select the volume to modify, and then choose Actions, Modify Volume.

    3. The Modify Volume window displays the volume ID and the volume's current configuration, including type, size, IOPS, and throughput. Set new configuration values as follows:

      • To modify the type, choose a value for Volume Type.

      • To modify the size, enter a new value for Size.

      • To modify the IOPS, if the volume type is gp3, io1, or io2, enter a new value for IOPS.

      • To modify the throughput, if the volume type is gp3, enter a new value for Throughput.

    4. After you have finished changing the volume settings, choose Modify. When prompted for confirmation, choose Yes.

    5. Modifying volume size has no practical effect until you also extend the volume's file system to make use of the new storage capacity.

    3) Extend the volume's file system manually (AWS Reference)

    1. To check whether the volume has a partition that must be extended, use the lsblk command to display information block devices attached to your instance.

      enter image description here