Couple of ways for increasing root volume size in your EC2 instances.
Approach 1: Modify Existing Volume
This is probably the easiest way to get the resized volume up and running. But, it’s going to take up some time to resize the existing volume, higher the existing volume size, longer the time it’s going to take to completely resize it to your desired capacity. Next, before we move on to modifying volume it’s important to back up the existing volume. Take a snapshot of the existing volume, just to make sure we don’t lose any data if something fails along the way.
Once the snapshot is ready, make sure to stop the running EC2 instance before the next step. Now, let’s go ahead and extend the volume by using the modifying volume option.
Here are the steps:
- Screenshot of the instance which we are going to resize.
- Make sure to stop the instance before going further.
- Detach the volume.
- Modify the volume to your desired capacity.
- Process of modifying the volume is time consuming depending on the size of your volume, please be patient through the process.
- Re-attach volume to the EC2 instance.
- Screenshot of the volume post resize.
- List of mount types of all our volumes.
Approach 2: Using Snapshots
This approach works great if you already have everything like flask libraries, nginx server and any other libraries or framework wherein we have setup the environment already. Else, we will have to spend a considerable amount of time doing the same. Or even if we want to spin up more EC2 instances with the same environment.
Make sure to stop the instances before going further.
We will need to create a new volume by providing a snapshot id of the volume you had previously taken the snapshot of. Once the volume is created, you will be required to detach an older volume of a smaller size and attach the new volume which was created with a snapshot. If all the steps were followed correctly, we should be able to see the extended size of your root volume.
- Make sure to stop the instance before going further.
- Detach the volume.
- Create a snapshot of the volume you want to be resized.
- Once the snapshot is created, we move on to creating new volume of the desired capacity from the snapshot created previously.
- Re-attach volume to the EC2 instance.