AWS Guides: How to increase your EC2 Linux root volume size

awsThis guide applies to increasing the root volume size of an EBS EC2 Linux instance on AWS. By default most Linux instances come with an 8gb root volume unless you changed it at first launch. If you are one of the people that forgot to do this or you just simply need to extend the volume take a look at this guide. Be sure to also check out my other guide on how to increase the size of a Windows EBS Volume.

I started out with an Amazon Linux instance and an 8gb volume. First you want to navigate to your AWS Console and then click EC2 and then Volumes on the left panel. Find the volume that your instance is attached to and right click and create snapshot.

createsnapshot

A new window will pop up and you can fill in a name and description and then select ‘Yes, Create’.

snapshotdescription

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.

snapshot

snapshotcompleted

Once the snapshot is complete, right click on the snapshot and select ‘Create Volume’. Now pay attention here because this is where you specify the new volume size which is larger than previously, for this example I chose 100gb. 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-2a. You must also choose either a standard volume or Provisioned IOPS. Once done, press ‘Yes, Create’.

createvolume2

Once the volume is created, navigate over to your EC2 Instances section and go ahead and stop your 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.

detach-volume

Once the volume is detached, go ahead and attach the volume you created to the instance by selecting the 100gb volume, right click, and attach the volume to your instance specifying the mount point as /dev/sda1.

attach-volume

You may now 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). You may also need to switch to root if logged in as ec2-user, use ‘sudo -s’ to accomplish this. Now the attached volume will still appear as 8gb until you extend the volume with ‘resize2fs /dev/xvda1’ as seen in the code below. Your mount points may vary, you can check these with either ‘mount’ or ‘fdisk -l’.

[root@ip-10-254-59-62 ec2-user]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G  957M  6.9G  12% /
tmpfs                 829M     0  829M   0% /dev/shm
[root@ip-10-254-59-62 ec2-user]# resize2fs /dev/xvda1
resize2fs 1.42.3 (14-May-2012)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 7
The filesystem on /dev/xvda1 is now 26214400 blocks long.

[root@ip-10-254-59-62 ec2-user]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1             99G  969M   98G   1% /
tmpfs                 829M     0  829M   0% /dev/shm
[root@ip-10-254-59-62 ec2-user]#

If you have made it this far, congrats on your expanded volume. Let me know if you have any questions.

AWS Guides: How to resize a EC2 Windows EBS Volume

The following guide will help you resize an EBS volume on a Windows instance inside EC2 on AWS. The task can be a little daunting but is quite easy once you have done it the first time. Remember this guide only helps with increasing the size of the EBS volume not decrease it. Please be sure to also check out my guide on how to increase the root volume size of an Ec2 Linux Volume.

Step 1: Stop the instance that you are going to perform the volume resize on. (Note: This step is recommended but not required).

Step 2: Create a snapshot of the volume attached to the instance. This can be accomplished by navigating to the EC2 section of the AWS Console and selecting volumes, the ‘attachment information’ column will show which instance the volume is attached to. Once you find the volume, right click and select create snapshot. The details of the snapshot can be whatever you want.

Step 3: Navigate to the snapshot section of the EC2 console on the left side. Once the snapshot creation completes (Note: this can take minutes to hours depending on the size of the volume). Right click on the snapshot that you just created and select ‘create volume’. Make sure you create the volume in the same availability zone as the instance. On the next screen you can specify a larger volume size than previously, for example if the original volume was 30gb you can specify 100gb now (Note: You cannot specify a volume size smaller than the original snapshot size).

 

Step 4: Once the new volume is created, detach the original volume from the instance and attach the new volume that was created. (Note: Make sure you mount the volume on the same mount point as it was originally notated by ‘Device’ in the picture below). The root volume is usually /dev/sda1.

Step 5: Start the instance.

Step 6: The new volume size will not be reflected immediately inside the Windows instance so you will have to do one more thing. Connect to your Windows instance with Remote Desktop and open the start menu. In the run menu or the bottom of the start menu on newer versions of Windows type ‘Diskmgmt.msc’ and press enter. On the Disk Management window you want to find the drive you want to resize this is usually the C: drive for the root volume. Right click on the drive and say Extend, follow the wizard and voila you have resized your volume on EC2.

If you enjoyed the guide please like it and share with your friends, please also share your experiences in the comment section below.

AWS Guides is a series where I share my experiences with hosting on Amazon Web Services.