# How to increase storage of AWS EC2 server without deleting data

## **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**
    

![](https://lh7-us.googleusercontent.com/LrQVCI0b_XGUQkcRJ7WDbOf2Pp1GveE12ikEbSzdTF4fKzBPJUXBEsbmM0bfTvUBDME2AkWBIh5fjxSCHWRNxXSMZcN6nhjv-Dj8zZgp6Oqg4l9L1iSB86TcqYxKCfffO-Fc-PCsew8v2mZNQfJHz8Q align="left")

![](https://lh7-us.googleusercontent.com/DOWenGY0Io0V2zSPEdBC1SvWh7HlU6oV2_urpAvzD8AhzxLXBr1VmOK2V29KFoPiFXSjHac6pb7_GETqvBYESI_fXjP-NG9OeCmasjbGWwyPaCWLyprOZKPvM1WmcaoyItipEustlNMulKOsQ6_IBpU align="left")

### **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:

```bash
lsblk
```

![](https://lh7-us.googleusercontent.com/vZcXKTAyymrfJ5ua1StMA9LxMmfw0YwfvfdCLMfAtcwGMACxqwcsNPz-j2wTm884oFbhXwnT6naaAN_uAaYgUFmkr5eVvg50YMEulikEllmj6GUXucdqZbBd3UH17lPpLJEXn_lTOfK0t-M3dyIZhzg align="left")

#### 3\. Extend Partition

Use the following command to extend the partition:

```bash
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:

```bash
df -hT
```

![](https://lh7-us.googleusercontent.com/PMgyvobh7W2FifukwsTDtnrx1z7saykYIjy3r09gXQftb8ZK4Xl89ZQrnlLXYrqDNMzp66sd_YHZAoHBY4zkfLTu4fACisf5D8bZI5Gf1xr1Bid0l_569MJFRw7mzcHAbTN3yej7vL83cUboNkuj_4c align="left")

#### 5\. Resize File System

Finally, resize the file system using:

```bash
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](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html).

If you have any questions or suggestions, feel free to leave them in the comments section below or connect with me on [LinkedIn](https://linkedin.com/in/priamjain)
