Updated: Jul 29, 2021
Persists EBS volume beyond the life of an EC2 instance, take snapshot & restore the EBS volume with increased storage capacity to a new instance.
1. Learn to persist EBS Volume beyond the life of an EC2 instance.
2. Resolve the problem of storage capacity for EC2 instance.
Step 1: Create a Linux Instance as follows:
Click on Instances option in left navigation pane so as to be directed to following page.
Click on Launch Instance button on top left.
After clicking on the launch instance you will be redirected to this page. Here search/select Amazon Linux 2 AMI.
Choose an Instance Type over here.
Select General purpose type t2.micro Instance Type.
Click on Next: Configure Instance Details at the bottom right of the screen.
Here you will Configure Instance Details.
In the Subnet field select on the drop down list and select any one of the Subnets. Note This subnet for reference afterwards.
In the Auto-assign Public IP field select on the drop down list and select Enable option.
Click Next: Add Storage at bottom right of screen.
Step 2: In the step for Add Storage, click on the Add New Volume. Let everything be default. Mention the required size of volume in GB. 50 GB in our case.
Click on Next: Add Tags button in the down right corner.
Click on the Next: Configure Security Group at the bottom right of the screen.
Configure Security Group
Create a new security group and name it as LinuxSG
In the description enter the following text: Security Groups for Linux Servers
Keep the default SSH rule.
Warning: Rules with source of 0.0.0.0/0 allow all IP addresses to access your instance. We recommend setting security group rules to allow access from known IP addresses only.
While using this feature for production make sure the known IP address is entered.
Click on Review and Launch button on the bottom right corner
Review Instance Launch
Here are all the details regarding your instance. Read them once and check if all the configurations are correct
Click on the Launch button at the bottom right corner. This will launch your instance.
After you click the Launch button here you will be asked to select/create KEY-PAIR. Choose an existing key pair option from the drop down.
Acknowledge the key pair and launch the instance.
Click View Instances button at bottom right of the screen to see your launched instance.
Check if the instance is in running state.
Step 3: In the left panel of the AWS console go into Volumes under Elastic Block Store. Here you will see our 2 volumes created (One which was added by default with the instance and the other we added extra)
Name these two volumes as ROOT and DATA below the name category by clicking the pencil icon in the name column.
Step 4: Select the DATA volume. Go to Actions and click on Create Snapshot option.
Give details of the snapshot in the Create Snapshot pop-up window and click on Create Snapshot.
Step 5: Go to the Snapshots option on the left panel and check that the snapshot has been created.
Step 6: Now Terminate the Linux Instance
Click on drop-down menu besides Actions button
Select the Instance State and click on Terminate
Step 7: Go to Snapshots under Elastic Block Store. Click on Actions and select Create Volume.
Initially the size of volume in this case is 50 GB.
We see the same value in the new Modify Volume pop-up window. Increase it to different value. E.g. 100 GB.
Note the subnet and choose the same subnet while creating its associated Instance in future.
Click on Create Volume.
Thus the old volume is modified into a new volume with increased size of 100GB.
Step 8: Go to EC2. Create Linux Instance and configure it in the above noted subnet. Configure it to have only ROOT volume.
After creation on the instance, in EBS, make sure that the new ROOT volume is in in-use state. The modified volume will be in available state.
Step 9: Go to Volumes. Select the DATA volume. Go to Action -> Attach Volume.
In the pop up window select your newly created instance in the Instance text field. Click on Attach button.
Now the volume is successfully attached to the instance.
Note: If you no longer need this instance and the volume make sure to terminate the instance and delete the volume as well as snapshot.
Was this document helpful? How can we make this document better. Please provide your insights. You can download PDF version for reference.