Increase EC2 root volume size


Introduction:
To increase EC2 Linux server's root volume size.

Why was this tutorial made? 
I had this issue in one of my EC2 instances where I was running Codeigniter Project.

So what was the problem?
Codeigniter pop-out a message saying "fopen(/var/lib/php/sessions/ci_session2be254f027bc9251bf55ddd02b09c35e5ff7a7c1): failed to open stream: No space left on device"

Now I, connected to my instance using Public DNS ran df command ( report free disk space )


By running Df command, I made sure the problem was with the root volume of my EC2 instance.

While creating a new instance in EC2, most Linux instances come with an 8GB root volume unless you changed it at first launch. So in my case, I made use of 8GB Volume.

Solution

Now, we need to increase the space of root volume attached to our EC2 instance.
Step 1:  Navigate to your AWS Console and then click EC2 and then Volumes on the left panel.

 Step 2: Finding the volume that your instance is attached to. Infomation about the instance could be seen in the Additional Information section.


Step 3:
a) Select the volume right click




b) Create a new snapshot by proving the information like name and description. Finally, click on Create.




Once your snapshot is started creating, navigate over to the snapshot section of the EC2 Console on the left side panel. You will then look for the snapshot you just created with the same name you gave it. This may take a while to for the snapshot process to complete.



Step 4: Once the snapshot is complete, right click on the snapshot and select ‘Create Volume’.



Now specify the new volume size ( The size of the EBS volume in GiB. Note that 1 GiB = 1024^3 bytes, whereas 1 GB = 1000^3 bytes) Please also note that you need to make the volume in the same Availability Zone as your instance, mine happens to be in us-west-1b.

Once done click on Create Volume button in the right corner.

Step 5: Now the volume is created, navigate over to your EC2 Instances and stop the instance. Once stopped, go ahead and detach the original root volume from the Volumes section of the EC2 Console. To do this you simply find the volume attached to your instance and right click, and select detach.



Step 6: Once the volume is detached, go ahead and attach the volume you created to the instance by selecting and right-click, and attach the volume to your instance specifying the mount point as /dev/sda1.
Last Step: Now you need to start your instance again.
Once your instance is back and running go ahead and SSH into the instance (Note: Your IP address may have changed or you may need to re-associate your elastic IP address).



Now we can see that the disk is empty.


Comments

Popular posts from this blog

Using Redis in PHP for handling background Jobs

DrillDown using Flot Charts

Securely setting Files and Folder permissions on Laravel 5