Increasing AWS EC2 ubuntu instance disk space

17,062

Solution 1

No, you're missing something - you end up with your old partition size.

Here's how you do it (pay attention to resize2fs / xfs_growfs commands):

Resizing the Root Disk on a Running EBS Boot EC2 Instance.

Example:

# In case your Filesystem is either ext2, ext3, or ext4
$ sudo resize2fs /dev/sda1

# Or if you have XFS
$ sudo apt-get install -y xfsprogs
$ sudo xfs_growfs /

Solution 2

As Chris Moore mentioned in a comment, the disk space is automatically increased on boot for any modern EC2 Ubuntu server, making this much easier. Here's the steps:

  1. Open EC2 -> Elastic Block Store -> Volumes. Find the volume you want to increase by looking at the Attachment Information column.
  2. Select the volume and click Actions -> Modify Volume, then select the new volume size you want.
  3. Open EC2 -> Instances -> Instances, select your EC2 instance and click Actions -> Instance State -> Reboot.

You're done! 🎉

Solution 3

In addition to the answer above, Amazon put out a guide as well. I used both resources when I was expanding my volume.

Share:
17,062
Sangram Anand
Author by

Sangram Anand

Updated on June 12, 2022

Comments

  • Sangram Anand
    Sangram Anand about 2 years

    i have a ubuntu instance(CRON server) of volume size 50gb. I want to increase its size to 100gb+

    Here are the steps i want to follow,

    1) create a snapshot of the volume attached to CRON server.

    2) create a volume with the newly created snapshot, by specifying the size you need. In my case 100gb.

    3) detach the existing volume for cron server by running the command

    ec2-detach-volume old_volume_id cron_instance_id sda1
    

    4) attach the new volume (i.e. 100gb ones) to cronserver

    ec2-attach-volume new_volume_id cron_instance_id sda1
    

    please correct if am missing or not using a correct step.

  • Chris Moore
    Chris Moore over 10 years
    This step is unnecessary on modern Ubuntu instances. It is done automatically at boot time.
  • Roman Newaza
    Roman Newaza over 10 years
    Look at the post date.
  • Chris Moore
    Chris Moore over 10 years
    It's an old post, with outdated information. I was updating it, so that it is still true. Is that bad? If you prefer that your answer stand for historical reasons without being marred by the presence of the truth I don't mind deleting my comment.
  • Roman Newaza
    Roman Newaza over 10 years
    The answer is still useful for other, more stable distros than Ubuntu.
  • Almenon
    Almenon over 2 years
    Tested and confirmed working on Ubuntu 18