DEV Community

James Murdza
James Murdza

Posted on • Edited on

3

How to extend the disk space of an AWS EC2 instance

This works for instances running Amazon Linux:

0. If you need to free up space quickly

Delete some journals:

sudo journalctl --vacuum-size=100M
Enter fullscreen mode Exit fullscreen mode

1. Add space in the AWS console

  1. Go to EC2, and select your instance.
  2. Scroll to the horizontal tab bar, and click storage.
  3. Click on the volume ID.
  4. Select the volume, and under actions, click "Modify Volume". If this is grayed out, you have to wait.
  5. Enter the new disk size and click modify.

2. Grow the partition

  1. Determine the partition you want to grow:

    sudo lsblk
    
  2. Use growpart to grow the partition, changing xvda to the name of the partition you just determined:

    sudo growpart /dev/xvda 1
    
  3. Extend the filesystem to use the additional space:

    sudo resize2fs /dev/root
    

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay