Long time ago, I was in a situation where I miscalculated the volume size of an AWS EC2 instance, so I had to increase the data disk size. I’m sure this could happen to everyone once in a while. Although updating the disk size is a one-minute task, additionally, you need to do some configuration on the Linux OS side as well. So, here are the steps.
- Linux bash environment
Step 1. Verify the disk size has changed.
Step 2. Extend the partition. For example, expand the size of the device called
nvme0n1, partition number
sudo growpart nvme0n1 1
Step 3. Now, verify the partition size using the same command from Step 1:
Step 4. Extend the filesystem mounted in the root directory
- XFS file system:
sudo xfs_growfs -d /.
- Ext4 file system:
sudo resize2fs /dev/nvme0n1p1.
Step 5. Verify file system extension:
If you have any feedback or constructive criticism, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.