In Amazon AWS, this is a process you can use to increase the size of a EC2’s primary disk without having to reboot the host.
Let’s assume you have an EC2 linux host and just increased the disk from 10 Gb to 20 Gb because you needed more space. Usually, a reboot will bring the host online with the new space ready to go. But if you can not reboot the EC2, use this to get the disk updated right away.
You will need to SSH into the EC2 instance.
# to get the starting sector. Make a note of the sector. You will need this later
# Fdisk to the drive to expand
d to delete the first partition.
n to create a new partition.
p to indicate that it will be a primary partition.
1 to indicate that it will be the first partition.
The next step is very important, fdisk will ask for the first sector of the new partition. Use the number you noted earlier from the fdisk -l step.
Now fdisk will ask for the last sector. By default, fdisk will provide the last sector of the disk so use that default value.
w and fdisk will write the partition table to disk.
Now run partprobe followed by resize2fs with the drive designator. This will complete the resize.
partprobe resize2fs /dev/xvda1
Check the new size of your disk and you should be ready to go.