Changing the partition size for a root partition or any other partition is just a little bit different when you’re working in the cloud. Today I’m going to show you how to change the root partition of an EC2 instance running Linux.
Resizing the root partition on an Amazon EC2 instance starts by stopping your instance.

First, go to volumes on the left-hand EC2 navigation control panel. Once you’re there, look under attachment information and identify the volume that is attached to the instance on which you want to change the root partition.

Right-click on the volume you want to resize and select Create Snapshot.

Fill out the details of the snapshot you’re creating. This will help you identify it in your snapshot inventory.

Select Snapshots on the left hand side of the EC2 control panel. From here you can see your snapshot being created. Make sure you remember what availability zone your running instance/server is in; what you do next will require that information

Right hand click on the snapshot you just created and select Create Volume from Snapshot.

Enter the new size you would like the partition to be, select the same availability zone of your running instance then click on yes, create.

Head back over to volumes in the EC2 control panel. Once there, select the root volume we just created an image of, right click on it, and select detach volume. We are doing this because now that we created a new 10gig volume, we are going to attach that new volume in place of the old volume.

Now right click on the new volume we created.

Attach the volume

It’s important to make sure the volume is attached as /dev/sda1, so change the volume name. If you do not do this, your instance will NOT be able to turn back on.

As soon as the volume is attached, go back to your instances and turn your instance back on.

Login to your instance and run df -m as sudo or root. You’ll notice that your partition size is still the same even though we created a larger volume. Now we need to resize the partition inside of Linux.

Make note of the partition name; in our case it’s /dev/xvda1. Now type resize2fs /dev/xvda1 at the command line.

Now it starts to resize the root partition…

Once complete, type df -m to view the new root partition size and verify that it worked.

We see that /dev/xvda1 is now 10gig vs 1gig.

All Done!

AWS Labs

11 responses to “Resizing Root Partition on Linux in Amazon EC2”

  1. […] Printer from Gnu/Linux without Linux […]

  2. […] […]

  3. Jerry says:

    Nicely done! This is a great write-up to resize an EC2 root partition. You made it so simple. Your instructions worked perfectly. Thanks a lot!

  4. Roberto says:

    Thanks man, this was helpful!

  5. Raga Kuswardhono says:

    Thank you, it’s working on mine, nice instructions.

  6. chris says:

    Well, I am struck with creating a root volume is 1000 GB , when I create a volume from the snapshot it is not getting reduced than 1000.

  7. Ramil Menzeleev says:

    Great job! It is significantly more simple than AWS instructions and it works. Thank you!

  8. Radek Bokuvka says:

    Well done! Straightforward and easy to follow instructions.

  9. kumaran says:

    Like for any /home and /var and /var/log Do we need to stop instance? Or on the fly is it possible?

Leave a Reply

Your email address will not be published. Required fields are marked *

Get actionable training and tech advice

We'll email you our latest articles up to once per week.