DEV Community

James Murdza
James Murdza

Posted on • Edited on

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)