DEV Community

Walter Nascimento
Walter Nascimento

Posted on

How to Increase Partition Size on an AWS Instance

In cloud computing environments like Amazon Web Services (AWS), it's common to need to increase the size of partitions on instance disks. This might be necessary to accommodate more data, expand available storage space, or simply optimize infrastructure. This guide will provide a step-by-step process on how to increase the partition size on an AWS instance, using a practical example and demonstrating the necessary commands.

Before You Begin: It's recommended to take a snapshot of the disk before starting the partition resizing process. This will help protect your data and allow you to restore the instance to a previous state if needed.

Step by step

Let's assume we have an AWS instance with a root partition of 30GB that we need to increase to 50GB.

Check Current Disk Structure

  • Connect to the AWS instance using SSH.
  • Run sudo lsblk to view the structure of the storage devices.
nvme1n1       259:0    0  200G  0 disk /storage
nvme2n1       259:1    0  150G  0 disk 
nvme0n1       259:2    0   50G  0 disk 
β”œβ”€nvme0n1p1   259:3    0   30G  0 part /
└─nvme0n1p128 259:4    0    1M  0 part 
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ NOTE: The root partition (nvme0n1p1) is only using 30GB of the 50GB disk.

Check Current System Usage

  • Run df -hT to check the current usage of the filesystem.
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1 xfs        30G  3.3G   27G  11% /
/dev/nvme1n1   ext4      197G   87G  101G  47% /storage
Enter fullscreen mode Exit fullscreen mode

Resize the File System

  • Since the filesystem is XFS, execute sudo xfs_growfs -d / to resize it.

πŸ’‘ NOTE: that / is where it is mounted
πŸ’‘ NOTE: For ext2/3/4 filesystems, use sudo resize2fs /dev/nvme0n1p1.

Verify the Final Result:

  • After resizing the filesystem, run df -hT again to verify the final result.
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1 xfs        50G  3.3G   47G   7% /
/dev/nvme1n1   ext4      197G   88G  101G  47% /storage
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ NOTE: Now, the root partition has been successfully extended to 50GB, utilizing all available space on the disk.


Note on sudo lsblk Command Output

It appears that the lsblk command is showing two subpartitions for the root disk (/dev/nvme0n1). This happens when there is a GPT partition table and a partition reserved for BIOS (usually 1MB). The root partition (nvme0n1p1) has been extended to 50GB and is mounted as /. The nvme0n1p128 partition is reserved for BIOS and is not used for storing data. This configuration is common in modern systems using the GPT partition table.

Thanks for reading!

If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!

😊😊 See you later! 😊😊

Support Me

Youtube - WalterNascimentoBarroso
Github - WalterNascimentoBarroso
Codepen - WalterNascimentoBarroso

Top comments (0)