«

»

Aug 06 2013

How to resize an EC2 root partition

Apparently, MongoDB needs at least ~3GB of free space to initialize and start. This required resizing the root partition of a couple of Amazon EC2 instances. Fortunately, this is an easy procedure! Here are the steps followed:

1. Go to the Instances management interface and stop the instance in question. Take note of the availability zone it currently resides in, as you will need that information later.

2. Go to the Volumes management interface, find the one being used by the instance (see the “attached to” column, it will have the instance’s name) and select the Take Snapshot option.

3. Go to the Snapshots management interface and find the newly created snapshot. Choose it and select the Create Volume option. Then, you must enter the new (increased) size and select the same availability zone as the EC2 instance (from step 1).

4. Go to the Volumes management interface, find the OLD volume, choose it and select the Detach Volume from instance option. Then, find the NEW volume, choose it and select the Attach Volume to instance option. Here you select the instance you want to have the increased partition and CHANGE THE DEVICE MOUNT POINT TO: “/dev/sda1″ (no quotes).

5. After the new volume is attached, you go back to the Instances management interface and start the EC2 instance again. Wait for it to come back online and connect to it through SSH.

6. Login as root (sudo, etc) and run the “df -h” (no quotes) command to get a list of the mounted partitions. Here you will see the new one, more likely mounted at “/dev/xvda1″. Notice that the system doesn’t report the correct (increased) size yet. To fix that you will have to extend the partition in order for it to cover the rest of the free space of the volume. To do so, simply run the command: “resize2fs /dev/xvda1″ (no quotes).

All done!

More in General News
THE FINAL MOMENTS OF KARL BRANT
AthCon Trailer 2013
Adding an HP printer to BackTrack 5
CSIS: Raising the Bar for Cybersecurity
How to graphically control a remote machine
Close