Resizing An EC2 Root Partition Running Ubuntu 13.04
If you have a production computer on EC2 you should periodically check how much space the root partition has. By default, for Ubuntu AMIs Amazon provides 8GB of space, but as your data set, log files, etc continue to grow, you may experience a crash if your server runs out of space and your data base saves or log points start to fail. To see how much space you have, start by running the following command:
As you can see, I am currently using 26% of the 8.5GB allocated by Amazon. The rest of the instructions will explain how to re-size this root partition and add extra space.
-
First things first, stop you instance from the EC2 managment console.
-
Go to volumes, track down the 8GB volume that is attached to the instance you just stopped, and detach it from the instance.
-
Once the volume has successfully detached, take a snapshot of it.
-
Once the snapshot has finished processing, create a new volume from the snapshot. You are obviously going to increase the size, but it is important to make sure the volume is in the same availablity zone as your stopped instance.
-
Once you have created the new volume, attach it to the stopped instance. It is important that you attached it to
/dev/sda1
, otherwise you will not be able to log back into your instance. -
Once the volume is attached, re-start your instance and log back in. Do not forget that if you stopped your instance, the elastic IP has been un-associated from your instance, so you will need to re-associated it.
-
Once your back in, you can run df –si again, and you will see that the size hasnt actually changed - bummer. That is becuase you need to run the following command to finish off the process:
( /dev/xvda1 is where you volume is mounted, and you can see that from looking at the output of df –si)
Finally, run df –si one last time and see the new, larger volume: