How to Extend AWS NVMe Volumes with No Downtime
This article guide you to resize the EBS volume without rebooting.
In order to extend the volume size, follow these simple steps:
- Login to your AWS console
- Navigate to
EC2 -> Elastic Block Store -> Volumes
. Click on the volume that you want to resize, then selectActions -> Modify Volume
. It will open a popup. - Set the new size for your EBS volume (for example i’m increasing size form 8GB to 16 GB). and click modify. Click yes to confirm popup.
Now the volume has been resized, but it won’t reflect in the system. we need to extend the partition itself.
4. SSH into the EC2 instance.
i. List block devices attached to the machine.
sudo lsblk
ii. You can see that root partition is still 8 GB. Let's increase the partition to disk size.
sudo growpart /dev/nvme0n1 1
iii. Now partition size is increased to disk size. we can check using lsblk command.
sudo lsblk
iiii. Now we need to extend our filesystem.
if your filesystem is is an ext2, ext3, or ext4, type:
sudo resize2fs /dev/nvme0n1p1
if your filesystem is an XFS, then type:
sudo xfs_growfs /dev/nvme0n1p1
Now everything is done. You can check space type:
df -h
Congratulations You have successfully extended your EBS volume with ZERO downtime.