After expanding the size of an EBS volume on an AWS EC2 instance, you’ll need to expand the partition and the filesystem. Here are the steps:
- Confirm available storage with “lsblk” command.
- Expand the partition with “growpart” command like “growpart /dev/xvdi 1”. Of course you’ll need to change the device name to match your system. The partition number on the end will be “1” if there is only one partition on the device or can be changed to select a different partition. “growpart” is in the “cloud-guest-utils” package if it’s now already installed.
- Confirm new partition size with “lsblk” command.
- If using LVM then expand the physical and logical volumes:
- Reread partitions with “partprobe”
- Resize physical volume with “pvresize /dev/xvdi1”
- Expand logical volume with “lvextend -l +100%FREE /dev/vg_data2/lv_data2”
- Resize the filesystem to fill the expanded partition. Command will depend on the filesystem type:
- ext2/3/4 – “resize2fs /dev/xvdi1”
- xfs – “xfs_growfs /dev/vg_data2/lv_data2”
Now you should have the expanded storage available for use.
Here’s the man pages for these commands: