EC2 - increase storage without turn off instance
-
To increase the space on your AWS instance, follow these steps:
1. Check the Available Storage:
Before expanding, verify the disk space:df -h
2. Identify the Volume:
Find the attached volumes for your EC2 instance:Go to the EC2 Console.
Under Elastic Block Store (EBS), select Volumes.
Identify the volume attached to your instance.3. Modify the EBS Volume:
Select the volume you want to expand.
Click on Actions → Modify Volume.
Increase the size of the volume (e.g., from 8 GB to 20 GB).
Click Modify.4. Extend the Partition on the EC2 Instance:
After the volume is resized, you'll need to extend the file system to use the new space.For ext4 file system:
Verify the volume size:lsblk
Make sure the resized volume reflects the correct size.
Extend the file system:sudo growpart /dev/nvme0n1 1 sudo resize2fs /dev/nvme0n1p1
For xfs file system:
Extend the file system:sudo xfs_growfs -d /
5. Verify the Increased Space:
Check the disk space again:df -h
This process will allow you to increase the disk space without stopping the instance.
To check partition type
lsblk -f