Dynamic volume expansion of AWS T2 instances
Requirements: the original 30G storage of AWS T2 instance needs to be expanded to 200G.
1. Modify the volume size
Find Volume-> Select corresponding Volume-> Action: modify Volume
Expand from 30G to 200G, the status will be initialized after submission, and it will be successful when the status changes to in-use.
2. Extended partition
Using lsblk to see that the volume size has been expanded to 200G, but the partition size is still 30G.
Use the growpart command to expand the partition. Notice that there is a space between the device name and the partition number
Growpart / dev/xvda 1
3. Extend the file system
# View the file system type, which is XFS type
File-s / dev/xvd*
# install the xfsprogs tool
Yum install-y xfsprogs
# extending the XFS file system
Xfs_growfs-d /
You can see from the df-h command that it has been expanded to 200G.
Reference official website: https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html
Attached:
1. For ext4 file systems, use the following command
Pvresize / dev/xvdf
Lvextend-r-l + 100%FREE / dev/mapper/vg_mysqlbackup
2. If it is a LVM2 file system, use the following command
# expanding logical volumes
Growpart / dev/xvdb 1
# View pv name
Pvs
# expand pv size
Pvresize / dev/sdb1
# View lv name
Df-h
# expand lv size
Lvextend-r-l + 100%FREE / dev/mapper/vg_opt-lv_opt