One of the great uses of EBS volumes is there persistence, however, there often comes a time when the data outgrows the original size of the volume. It is a fairly easy matter to remedy this, however, there does tend to be a moment of downtime.
While many filesystems do have a method for ‘growing’, my filesystem preference has been, of late, XFS.
The basic procedure to grow an EBS volume with an XFS filesystem, would be as follows:
- (Freeze the filesystem with
xfs_freeze
if needed, or stop the instance, or detach the volume) - Take a snapshot of the volume (you can use the AWS console)
- Create a new volume from the snapshot, specifying a larger size
- Attach the new volume to an instance
- (For consistency, you should unmount the volume, run xfs_check, and remount the volume)
- Run
xfs_growfs -d MOUNTPOINT
The df command is quite handy during this, both to see the total space (i.e. before and after you grow the volume) (use df -h
) and for finding the type of filesystem you are using (use df -T
)
Bear in mind that you cannot shrink an XFS filesystem, only grow it.
Very true, if one wanted to make an XFS volume smaller, they would have to dump the data, remake the filesystem (mkfs), and restore the data – or, I suppose, create a new volume, and copy all the data over. Other file systems (ext3/4) are likely easier to shrink.