In AWS, you can generally extend the root (or other) volume of any of your EC2 instances without downtime. The steps slightly vary by OS, file system type, etc though.
On a rather default-configured AWS instance running the main marketplace Centos 7 image, I had to run the following commands.
- Find/modify volume in the AWS console “volumes” page under the EC2 service.
- Wait for it to get into the “Optimizing” state (visible in the volume listing).
- Run: sudo file -s /dev/xvd*
- If you’re in my situation, this will output a couple lines like this.
- /dev/xvda: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 134215647 sectors, code offset 0x63
- /dev/xvda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
- The important part is the XFS; that is the file system type.
- If you’re in my situation, this will output a couple lines like this.
- Run: lsblk
- Again, in my situation the output looked like this:
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- xvda 202:0 0 64G 0 disk
- └─xvda1 202:1 0 64G 0 part /
- This basically says that the data is in one partition under xvda. Note; mine said 32G to start. I increased it to 64G and am just going back through the process to document it.
- Again, in my situation the output looked like this:
- Run: sudo growpart /dev/xvda 1
- This grows partition #1 of /dev/xvda to take up remaining space.
- Run: sudo xfs_growfs -d /
- This tells the root volume to take up the available space in the partition.
- After this, you can just do a “df -h” to see the increased partition size.
Note, your volume may take hours to get out of the “optimizing” stage, but it still can be used immediately.
You can view the raw AWS instructions here in case any of this doesn’t line up for you when you go to modify your instance: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-modify-volume.html.