Managing Oversized Ebs Volumes in Production

Oversized EBS volumes are common in production; here's how to diagnose, remediate, and prevent them effectively.

JR

1 minute read

Oversized EBS volumes are common in production; here’s how to diagnose, remediate, and prevent them effectively.

Diagnosis

Start by identifying volumes where allocated space far exceeds actual usage. Use these methods:

  • Check current usage:
    df -h /mount/path  # For mounted volumes  
    
  • List EBS volumes:
    aws ec2 describe-volumes --filters 'Name=attachment.instance-id,Values=i-1234567890'  
    
  • Monitor via CloudWatch:
    Use VolumeIdleWrite and VolumeIdleRead metrics to spot underutilized volumes.

Remediation Workflow

  1. Create a snapshot of the oversized volume.
  2. Create a new volume from the snapshot with a smaller size (e.g., 100GiB → 50GiB).
  3. Attach the new volume to the same instance:
    aws ec2 attach-volume --volume-id vol-1234567890abcdef0 --instance-id i-1234567890abcdef0 --device /dev/xvdf  
    
  4. Transfer data from old to new volume:
    rsync -avx /mnt/old_volume/ /mnt/new_volume/  
    # OR use dd for block-level copy (slower, more thorough):  
    dd if=/dev/xvdf of=/dev/xvdg bs=1M  
    
  5. Detach old volume and reattach new volume with the original device name.
  6. Expand the filesystem (if needed):
    resize2fs /dev/xvdf  # For ext4  
    

Source thread: anyone else just leaving oversized EBS volumes alone because shrinking them sucks?

comments powered by Disqus