> For the complete documentation index, see [llms.txt](https://docs.iotcentral.in/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.iotcentral.in/docs/how-to-increase-volume-size-on-ec2-instance.md).

# How to increase Volume size on EC2 instance

Increasing the storage volume size of your Ubuntu EC2 instance on AWS involves a few steps. Here’s a step-by-step guide to help you:

#### Step 1: Modify the Volume

1. **Go to the EC2 Dashboard**: Sign in to the AWS Management Console, open the EC2 dashboard.
2. **Navigate to Volumes**: In the left-hand menu, under 'Elastic Block Store', click on 'Volumes'.
3. **Select Your Volume**: Find the volume attached to your instance. It will typically have an 8GB size.
4. **Modify Volume**: Right-click on the volume and select 'Modify Volume'.
5. **Increase Size**: In the 'Size (GiB)' field, enter '32' to increase the size to 32GB.
6. **Apply**: Click 'Modify'. It may take a few moments for the changes to take effect.

#### Step 2: Extend the File System

After increasing the volume size, you need to extend the file system on your instance.

1. **Connect to Your Instance**: Use SSH to connect to your EC2 instance.

   ```bash
   bashCopy codessh -i your-key.pem ubuntu@your-instance-public-dns
   ```
2. **Verify the Volume Size**: Check if the volume size has been increased.

   ```bash
   bashCopy codelsblk
   ```

   You should see the increased size for your root volume (e.g., `/dev/xvda1`).
3. **Extend the File System**: Depending on the file system type, you’ll use different commands. For `ext4` or `ext3` file systems:

   ```bash
   bashCopy codesudo resize2fs /dev/xvda1
   ```

   For `xfs` file systems:

   ```bash
   bashCopy codesudo xfs_growfs -d /
   ```
4. **Verify the New Size**: Check that the file system now uses the increased space.

   ```bash
   bashCopy codedf -h
   ```

#### Example Commands:

Here's a summary of the commands you might run on your instance:

```bash
bashCopy code# Connect to your EC2 instance
ssh -i your-key.pem ubuntu@your-instance-public-dns

# Verify the current disk layout
lsblk

# Resize the file system (for ext4/ext3)
sudo resize2fs /dev/xvda1

# Or, resize the file system (for xfs)
sudo xfs_growfs -d /

# Verify the new file system size
df -h
```

By following these steps, you should be able to successfully increase the storage volume size of your Ubuntu EC2 instance from 8GB to 32GB.

4o

ubuntu\@ip-172-31-35-193:\~$ lsblk NAME MAJ

RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 25.2M 1 loop /snap/amazon-ssm-agent/7983 loop1 7:1 0 55.7M 1 loop /snap/core18/2812 loop2 7:2 0 38.7M 1 loop /snap/snapd/21465 loop3 7:3 0 38.8M 1 loop /snap/snapd/21759 loop4 7:4 0 55.7M 1 loop /snap/core18/2823 loop5 7:5 0 25.2M 1 loop /snap/amazon-ssm-agent/7993 xvda 202:0 0 32G 0 disk ├─xvda1 202:1 0 7G 0 part / ├─xvda14 202:14 0 4M 0 part ├─xvda15 202:15 0 106M 0 part /boot/efi └─xvda16 259:0 0 913M 0 part /bootChatGPT

It looks like the volume size has been increased to 32GB, but the partition `/dev/xvda1` is still 7GB. You need to extend the partition before resizing the file system.

Here are the steps to extend the partition and resize the file system:

#### Step 1: Install `growpart` and `cloud-guest-utils`

Ensure you have `growpart` and `cloud-guest-utils` installed. These tools help in resizing the partition.

```bash
bashCopy codesudo apt-get update
sudo apt-get install cloud-guest-utils
```

#### Step 2: Extend the Partition

Use `growpart` to extend the partition `/dev/xvda1` to occupy the additional space.

```bash
bashCopy codesudo growpart /dev/xvda 1
```

#### Step 3: Resize the File System

Now resize the file system to use the newly available space.

For `ext4` or `ext3` file systems:

```bash
bashCopy codesudo resize2fs /dev/xvda1
```

For `xfs` file systems:

```bash
bashCopy codesudo xfs_growfs -d /
```

#### Step 4: Verify the New Size

Finally, verify that the file system has been resized to use the new space.

```bash
bashCopy codedf -h
```

#### Example Commands:

Here’s a summary of the commands you might run:

```bash
bashCopy code# Update package list and install necessary tools
sudo apt-get update
sudo apt-get install cloud-guest-utils

# Extend the partition
sudo growpart /dev/xvda 1

# Resize the file system (for ext4/ext3)
sudo resize2fs /dev/xvda1

# Or, resize the file system (for xfs)
sudo xfs_growfs -d /

# Verify the new file system size
df -h
```

After running these commands, your root partition `/dev/xvda1` should occupy the full 32GB space available on the volume.
