Extend EBS Volume
Tags: aws, ebs, volume, linux
Published: 2020-12-14 17:28:51

In this article, i want to share some information how to extend your aws ebs volume. In this example, i use ec2 instance with ubuntu operating system and mount gp2 ebs volume to that ec2.

EC2 instance is using non Nitro System or non NVMe volume

The scenario is, i have existing ebs volume with size 10 GB then i want to extend the volume to 20 GB

Here are few configuration steps to extend linux ebs volume:
1. Verify existing disk usage. Type `df -hT`

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/d00f1hqkh5fag886tay5.jpg)

2. Verify existing block device. Type `lsblk`

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m5mjyrdmuvl8uth5pbmh.jpg)

3. Based on example existing configuration, disk space is configured with 10 GB in size.

4. Go to aws console. Go to menu EC2 > Elastic Block Store > Volumes. Click on the block store that want to be extended

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/drmzwns12lh7g8ke42q1.jpg)

5. To prevent any unwanted issues, you can optionally create a snapshot for that ebs. Go to menu Actions > Create Snapshot

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6kamuw7onfput4maays3.jpg)

6. Configure snapshot description and tag (optional). After that, click Create Snapshot

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q2o74n1ftbpzu6ki40w8.jpg)

7. Wait until create snapshot request succeeded, then click Close

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9hiuh0ghz2uubr4o7k1f.jpg)

8. Verify snapshot has been successfully created. Go to menu Elastic Block Store > Snapshot. Then verify

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/w48v1856sipkcv979hbt.jpg)

9. Then, you can modify your EBS volume. Go to menu Elastic Block Store > Volumes. Click on the volume you want to extend. Then click Actions > Modify Volume

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gqtrndf1k1vtysriq1p0.jpg)

10. Modify volume size, after that click Modify

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p7mltlxqap6w2n800ghm.jpg)

11. Modify volume confirmation page will be prompted. Click Yes to continue

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gw1ctgxhb1q4d7ybd12t.jpg)

12. Wait until modify volume request succeeded

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f9jyqnrr05o6fxmv0u6g.jpg)

13. Verify volume has been modified

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pq0tdslzqrv07ccl4h7p.jpg)

14. SSH to your EC2 instance. Type this command:

    `sudo growpart [block_number]`

    in this example, the command should be:

    `sudo growpart /dev/xvda 1`

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/g6qzql31n53z4lqny7ct.jpg)

15. Verify block device size has been extended

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xh0qxltxph94dq63rbi0.jpg)

16. Resize your block device to new size. Type this command:

    `sudo resize2fs [block_number]`

    in this example, the command should be:

    `sudo resize2fs /dev/xvda1`

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cwi00c306wv2ryb2gs5a.jpg)

17. Verify your disk space has been extended

    ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vjxa5t12rgwwnyzqlac0.jpg)

For further reference you can also check aws documentation on this link:

[Link](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html)