How to increase storage of AWS EC2 server without deleting data

·

2 min read

Introduction

In this tutorial, I'll walk you through the steps required to increase the volume size of your EC2 instance on Amazon Web Services (AWS). As my storage needs grow, it's essential to be able to scale up my resources easily and efficiently. I'll be focusing on increasing my Elastic Block Store (EBS) storage and extending the partition accordingly.

Prerequisites

Before we begin, make sure you have the following:

  • Access to an AWS account with appropriate permissions.

  • An EC2 instance with Elastic Block Store (EBS) is attached.

  • Take a snapshot of your EBS ( just in case :) )

Steps to Increase Volume Size of My EC2 Instance

1. Modify EBS Volume

  1. Log in to your AWS Management Console.

  2. Navigate to the EC2 dashboard.

  3. Select the instance for which you want to increase the volume size.

  4. In the details pane, locate the EBS volume attached to your instance.

  5. Click on Modify

2. Resize Partition

Once I've modified the volume size, follow these steps to resize the partition on my EC2 instance:

1. SSH into My EC2 Instance

Open your terminal and SSH into your EC2 instance.

2. Check the Current Disk Layout

Run the following command to check the current disk layout:

lsblk

3. Extend Partition

Use the following command to extend the partition:

sudo growpart /dev/nvme0n1 1

Replace /dev/nvme0n1 with your disk identifier if it's different.

4. Check File System Usage

Check the file system usage with:

df -hT

5. Resize File System

Finally, resize the file system using:

sudo resize2fs /dev/root

Replace /dev/root with your root file system if it's different.

Conclusion

It's crucial to monitor your storage usage regularly and adjust resources accordingly to ensure optimal performance and scalability.

For more detailed information, you can refer to the official AWS documentation.

If you have any questions or suggestions, feel free to leave them in the comments section below or connect with me on LinkedIn