> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resizing Amazon EBS Volume

> Hands-on lab · 45m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/resizing-amazon-ebs-volume" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab Details

1. This lab walks you through the steps to launch an EC2 instance and resizing an Amazon EBS Volume in AWS.
2. Duration: **45 minutes**
3. AWS Region: **US East (N. Virginia) us-east-1.**

### Introduction

#### What is an Amazon EBS Volume?

##### Amazon EBS Volume

* Elastic Block Store volume is a **block level storage device** that can be associated with an EC2 instance
* EBS Volumes can be used as both **primary storage** and **secondary storage**
* The **primary EBS volume** acts as **root volume** and should be created and attached to the **instance at the time of instance launch.** Storage  can be increased in the future if needed. This primary EBS volume cannot be detached from the instance.
* The **secondary volume** can be **attached, detached and modified at any time.**
* An **instance** can have **one primary EBS** volume and **n number of secondary volumes**
* **One Primary EBS Volume** can be only associated with one instance, and we can attach a **single secondary EBS Volume** to multiple Instances, provided they are in the **same Availability Zone**.
* There are 5 types of EBS volumes:

  * **General Purpose SSD (gp2)**- Provides **balance of both price and performance** and is generally chosen by default
  * **Provisioned IOPS SSD (io1)**-- Most expensive of the volume types with the **highest performance** and well-suited for tasks with **heavy workloads**
  * **Throughput Optimized HDD (st1)**- A low-cost volume that focuses on optimizing throughput and is generally used for **large sequential workloads** dealing with big data warehouses. These volumes **cannot be used as root volumes** for EC2 instances.
  * **Cold HDD (sc1)**- least expensive of the volume types and specifically designed for **workloads** which are **accessed less frequently.** These volumes also **cannot be used as root volumes** for EC2 instances.
  * Magnetic (Standard) Previous generation magnetic volumes, which **cannot be used as root volumes** for EC2 instances

##### Resizing EBS Volumes

* In this digital world of **ever enlarging data**, it’s not enough to build solutions with hard-coded amount of storage that cannot scale.
* If the volume associated with the EC2 instance fills up, we have to increase the side of the volume.

##### Advantages of using EBS Volumes

* **High availability** and **flexibility**
* **Data** can be kept **persistently on a file system** even after shut downing the instance
* Enables **snapshots,** which capture the data stored at a point in time and can be restored at any time.
* The snapshots enable us to **create a volume and attach it** to another instance if needed.
* Can be **resized** at any time as and when required
* Comes equipped with encryption (and encryption-at-rest).
* EBS Volumes can be **attached, detached and associated** with other instances at any point in time (exception the primary volume)

### Architecture Diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/001.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=c9f89dda9999ba6d38d948c05ce9a8c9" alt="" width="760" height="520" data-path="images/labs/resizing-amazon-ebs-volume/001.png" />

### Task Details

1. Sign into the AWS Management Console.
2. Launching Amazon EC2 instance
3. Resizing the EBS volume

### Launching Lab Environment

1. To launch the lab environment, click on the **Start Lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with **IAM username**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

> **Note** : You can only start one lab at any given time

## Lab guide

### Lab Steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open Console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

   * Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. Otherwise, you cannot proceed with the lab.
   * Now copy your **Username** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign-in** button.
3. Once Signed In to the AWS Management Console, make the default AWS Region as **US East (N. Virginia) us-east-1.**

> **Note :** If you face any issues, please go through [**FAQs and Troubleshooting for Labs**](https://play.whizlabs.com/site/task_support/faqs-and-troubleshooting).

#### Task 2 : Launching Amazon EC2 instance

In this task, we are going to launch an EC2 Instance.

1. Make sure to choose the **US East (N. Virginia) us-east-1** region.
2. Navigate to **Services** menu in the top, then click on **EC2** in the **Compute** section.
3. Click on **Instances** from the left sidebar and then click on **Launch instances** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/002.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=f5c34edc6f588b221e6d513590c4c299" alt="" width="1615" height="316" data-path="images/labs/resizing-amazon-ebs-volume/002.png" />

4. Name : Enter **EC2 instance for Volume resize lab**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/003.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=e696d1cf4d521f566cc1e5c33006552d" alt="" width="961" height="191" data-path="images/labs/resizing-amazon-ebs-volume/003.png" />

5. **For Amazon Machine Image (AMI):** Search for **Amazon Linux 2023 kernel-6.1 AMI** in the Quick Start menu.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/004.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=e61b0463f02ce0a0debe2ebb1698be5f" alt="" width="1182" height="601" data-path="images/labs/resizing-amazon-ebs-volume/004.png" />

6. **For Instance Type:** select **t2.micro**

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/005.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=7e4c8c249043c2353bda854b4f1d3803" alt="" width="1161" height="220" data-path="images/labs/resizing-amazon-ebs-volume/005.png" />

7. **For Key pair:** Select **Create a new key pair** Button

   * Key pair name: **WhizKey**
   * Key pair type: **RSA**
   * Private key file format: **.pem**

8. Select **Create key pair** Button.

9. In Network Settings, click on **Edit**:

* Auto-assign public IP: **Enable**
* Select **Create new Security group**
* Security group name : Enter **MyEC2Server\_SG**

10. Check **Allow SSH from** and Select **Anywhere** from dropdown

* To add **SSH**,

  * Choose Type: **SSH**
  * Source: Select **Anywhere**

11. Keep rest thing Default and Click on **Launch Instance** Button.
12. Select **View all Instances** to View the Instance you Created
13. **Launch Status:** Your instances are now launching, Navigate to **Instances** page from left menu and wait the status of the EC2 Instance changes to running

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/006.jpg?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=7b02daf1ed1165f42d14c2c2199d8410" alt="" width="1110" height="87" data-path="images/labs/resizing-amazon-ebs-volume/006.jpg" />

#### Task 3 : Resizing the EBS Volumes

In this task, we are going to demonstrate how to resize an Amazon EBS volume associated with an EC2 instance.

1. In the EC2 dashboard, select **EC2 instance for Volume resize lab** and navigate to the **Storage** tab and then click on **Volume ID** present.

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/007.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=6d38e5db47442dab2fbc4f820eb2ecc6" alt="" width="1311" height="690" data-path="images/labs/resizing-amazon-ebs-volume/007.png" />

2. Select the **Volume** and then go to the **Actions** menu dropdown. Click on **Modify Volume.**

   <img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/008.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=421f3b1967f5518742e429a138f044ea" alt="" width="1536" height="591" data-path="images/labs/resizing-amazon-ebs-volume/008.png" />

3. Provide the **new Volume Size** you need to **increase** to, and also **note** that we are not able to **decrease the volume** size. In our case, I’m modifying from **8GiB to 20GiB** and then clicking on **Modify.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/009.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=4ed6c8f386b21bf52705cf380754a4c6" alt="" width="1006" height="404" data-path="images/labs/resizing-amazon-ebs-volume/009.png" />

4. Now, after modifying the volume, we need to **increase the partition** and **file system.** To do so, we need to **SSH** into the server with the key we downloaded while launching the server.
5. To SSH into EC2 Instance. Follow the below steps.

* Once the instance is created. Select the instance **EC2 instance for Volume resize lab.** Click on connect button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/010.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=5293537632e02b1b83e927b30f42a5e2" alt="" width="922" height="134" data-path="images/labs/resizing-amazon-ebs-volume/010.png" />

* Now select the EC2 instance connect option. We can see there are four options for connecting to EC2. You can use any of the given options to get in the console but for our lab, we are using EC2 instance connect.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/011.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=ab99e30195b461a46cfe7e8c9e899b1c" alt="" width="1013" height="569" data-path="images/labs/resizing-amazon-ebs-volume/011.png" />

* A new tab would be opened in your browser where we can see the console.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/012.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=041649716dd4f95677652713ffb1ab8e" alt="" width="830" height="297" data-path="images/labs/resizing-amazon-ebs-volume/012.png" />

6. Enter the command

   ```
   sudo su
   ```
7. Run the following commands.

   ```
   df -h
   ```

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/013.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=463a5cf4eb195ad35ab8b914e59a9e2a" alt="" width="591" height="225" data-path="images/labs/resizing-amazon-ebs-volume/013.png" />

The above command will **list the amount of free disk space available** in the server. You can also see that the drive volume which we have increased will not be added to it.

8. Now run the following command to see the **list of all the block devices** that are associated with the instance (which will show the increased size of the partition volume):

   ```
   lsblk
   ```

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/014.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=acad56ccb6ae368e805f1836883bc6ac" alt="" width="560" height="182" data-path="images/labs/resizing-amazon-ebs-volume/014.png" />

The root volume has a **partition /dev/xvda1** whereas the root volume (/dev/xvda) reflects the new size. This tells us the partition size needs to be extended.

9. Extend the size by using the following command:

   ```
   growpart /dev/xvda 1
   ```

10. Find the **file system** of the block devices associated with the EC2 instance by entering the following command:

    ```
    lsblk -f
    ```

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/015.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=12bea9b0be423a3e99a96fa97a527fcb" alt="" width="1101" height="211" data-path="images/labs/resizing-amazon-ebs-volume/015.png" />

11. The above command will provide us the **file system** of the block devices which will be one among the following types: **ext2,ext3,ext4 or XFS**

Our file system type is **ext4,** so for this file system, use the below command (also for ext2,ext4):

```
resize2fs /dev/xvda1
```

**Note:** **If the file system is** **XFS then run the below command**

```
xfs_growfs /dev/xvda1
```

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/016.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=a15921fad9134a22df4fdc3428c0c2b2" alt="" width="870" height="308" data-path="images/labs/resizing-amazon-ebs-volume/016.png" />

12. Now find the effective file system extended volume size,

```
df -h
```

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/017.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=abb3cf4351872599f3414d55e0c2f097" alt="" width="668" height="206" data-path="images/labs/resizing-amazon-ebs-volume/017.png" />

13. You have successfully launched an **EC2 instance and re-sized the root EBS volume** of the instance with **zero downtime**.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/018.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=40d32d2199d503fa86ac2e026522b3e8" alt="" width="1312" height="236" data-path="images/labs/resizing-amazon-ebs-volume/018.png" />

14. Similarly, we can resize the secondary volume associated with the instance in the same way.

**Note: Make sure that the Volume state is In-Use before validating the lab.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/tRuhen-qU3QM2UBZ/images/labs/resizing-amazon-ebs-volume/019.png?fit=max&auto=format&n=tRuhen-qU3QM2UBZ&q=85&s=e684b30553df3bf9fa695955b1670f11" alt="" width="1094" height="492" data-path="images/labs/resizing-amazon-ebs-volume/019.png" />

> ##### Do You Know?
>
> When you resize an EBS volume, the underlying data remains intact, and the volume retains all its existing data and configurations. The resize operation simply extends the capacity of the volume to accommodate the increased size.

1. Once the lab steps are completed, please click on the **Validation** button on the left side panel.
2. This will validate the resources in the AWS account and shows you whether you have completed this lab successfully or not.

### Completion and Conclusion

1. You have successfully used the AWS management console to launch an EC2 instance with 8GiB of root volume
2. You have modified the EBS Volume from 8GiB to 20GiB in the AWS Console
3. You have successfully accessed the EC2 instance using SSH via CLI.
4. You have extended the file system as well as the partition of the EBS volume.

### End Lab

1. Sign out of AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End Lab** from the IP Lab Portal dashboard.

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Launch an EC2 Instance** — Check whether an EC2 Instance is launched or not.
* **Validate EC2 Instance Type t2.micro** — Check whether the EC2 instance type is t2.micro.
* **Launch EC2 AMI type Amazon Linux** — Check whether the EC2 instance is launched using an Amazon AMI.
* **Modify EBS Volume** — Check whether the EBS Volume is modified or not.

## Related help

* [FAQs and Troubleshooting](/aws-saa/support/faqs-and-troubleshooting)
* [SSH into EC2 Instance](/aws-saa/support/ssh-into-ec2-instance)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.