-
Resize AWS EC2 EBS drives on the fly with zero downtime
Running out of hard drive space is a bane of every system administrator. Shutting down the server to add another drive then relaunching, or maybe you are lucky enough to have hot swappable hard drives making the process less painful. Well in the cloud on Amazon AWS you no longer need to shutdown or reimage your instance to expand your hard drives. If you are already using EBS backed instances, you now have the ability to modify your volumes on the fly.
This is how you resize your EBS drives on the fly on a EC2 instance. If you are using instance storage you cannot do this obviously, it only works on EBS backed instances.
The first thing you need to do is identify the drive you want to increase. If you have a small setup this could be very simple but if you have multiple drives, hopefully you mapped them out. The easiest way to identify the drive you want to use is to go through the AWS web console, and select the instance which contains the drive you want to modify.Scroll down until you see the root devices and block devices. If you have a simple setup, you probably only have 1 device. Select the drive you want to modify and you will get a pop up that will show you the EBS ID. Click on this link.
You are now taken to the volumes section of the EC2 console with the volume you want to modify already selected.
Select Actions -> Modify VolumeAdjust the size (or type if you wish – haven’t tested that yet) and select Modify.
You will be prompted that it will take a little bit for the resize to process but within a few minutes the extra space will be available on your drive.
This next step is important, you will more the likely HAVE to resize the drive to take advantage of this added space. How you do this depends on your operating system. In Windows you would open the disk management tool and extend your drives to use the added space.
On linux you will need to run the resize command that is applicable to your filesystem, it will be something like this:
# ext3 root file system (most common): sudo resize2fs /dev/yourdrive # XFS root file system (less common): sudo apt-get update && sudo apt-get install -y xfsprogs sudo xfs_growfs /
Leave a reply