DEV Community

Joe Block
Joe Block

Posted on • Originally published at unixorn.github.io on

Growing EBS Volumes in Place

Yesterday I had to grow a live filesystem on a server in EC2, without downtime. I do this just infrequently enough to not quite remember all the details without poking around the internet, so I’m documenting it all in one place.

Grow the volume

  1. Log into the EC2 console and find your instance. In the description tab, look at the block devices (bottom right as of August 2019) and find the volume you need to grow and get its volume ID.
  2. Find that volume in the EBS volumes list. Now is a good time to name it something useful like "InstanceName /data01" if you haven't already named it.
  3. Click Modify Volume, then give it a new size. It may take a minute or two to finish growing the volume, you'll see a percentage displayed.

Resize the filesystem

  1. Log into the instance and start a tmux or screen session to do all the work in. Getting disconnected in the middle of resizing the filesystem would be bad.
  2. Use lsblk to confirm that the EBS block device has increased to the size you expect.
  3. If you have partitioned your drive, do sudo growpart /dev/xyz1 0 to grow the partition.
  4. Check /etc/fstab to see what format the filesystem is.
  5. If you're using xfs, sudo xfs_growfs /dev/DEVICE. If you're using ext2, ext3 or ext4, do sudo resize2fs /dev/DEVICE. If you're using ext2 or ext3, seriously consider replacing this filesystem with an ext4 one during your next downtime window.
  6. Wait. Depending on how much larger the EBS volume has become and the instance type, it can take several minutes for the filesystem to finish growing.
  7. Confirm the new size with df

Discussion (0)