Increase the Size of AWS EC2 root disk without a reboot

8-5-2019

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 -l

# Fdisk to the drive to expand

fdisk /dev/xvda

then press d to delete the first partition.

then press n to create a new partition.

then press p to indicate that it will be a primary partition.

then press 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.

Press 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.

 

Tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
17 + 5 =