Create EBS Volume Snapshot and Attached to Another EC2 Instance in AWS (Amazon Web Services)

Create EBS Volume Snapshot and Attached to Another EC2 Instance in AWS (Amazon Web Services)

In this article,we will see Create EBS Volume Snapshot and Attached to Another EC2 Instance.

Implementation Steps

  1. Launch Linux EC2 Instance.
  2. Connect to Linux EC2 Instance through putty.
  3. Mount an EBS Volume to your Linux EC2 Instance.
  4. Create Snapshot from EBS Volume.
  5. Create Volume from Create Snapshot.
  6. Launch Another Linux EC2 Instance.
  7. Attach EBS Volume to your Another Linux EC2 Instance “My Linux 1”.
  8. Connect to Second Linux EC2 Instance through putty and verify files.

First, we need to AWS Console page by using below link.

https://aws.amazon.com/console/

Click on sign in to Console button.

Logging to aws account

Login using username & password and click on sign in.

Enter to AWS Management Console

We can see the AWS Management Console Dashboard.

Go to Services, under the compute module click EC2 service to open.

Launch Linux EC2 Instance 

Go to Instances and click on Launch Instance.

Choose an Amazon Machine Image (AMI)

Select the Operating system of the EC2 instance by choosing any of the Amazon Machine Images (AMI). Select the Microsoft Amazon Linux AMI.

Choose an Instance type

Choose the Type of instance depending on your requirements.

Instance types comprise of varying combinations of CPU, memory, storage, and networking capacity.

select the default option of t2.micro – this instance type is covered within the free tier. Then click on Configure Instance Details.

Configure Instance Details

Configure EC2 instance details as per requirements of your environment and click on Add Storage.

Add Storage

Here, we can see root volume by default and size of 8GB

Add a new volume “EBS” and the size is 10GB.

Click on Add Tags.

Add Tags

Tags assist in easier identification and classification of the various instances in your AWS environment.

Click on click to add a Name tag to provide name for our server.

Provide the name for the Linux virtual machine for easier understanding and click on Configure Security Groups.

Configure Security Group

A security group allows configuring firewall rules to allow traffic as needed. Only one rule has been added to allow remote connection.

SSH Is enough to connect to our Linux virtual server and click on Review and Launch.

SSH – Secure Shell

Review Instance Launch

Review and confirm the configuration of the instance. Click on the Edit button on each configuration item to make changes and click on Launch.

Select an existing key pair a Key Pair and Launch Your Instance

To connect to your virtual machine, you need a key pair. A key pair is used to log into your instance and Select an existing security group and click on Review and Launch.

Click on Launch Instance  to start your Linux Server instance.

click on View Instances to view the instance you have just created and see its status.

We can see Linux Server which was created earlier.

 

Verify volumes of your Linux EC2 Instance.

Go volumes,we can see two volumes attached to Linux EC2 Instance.

The first one is root volume and second one is EBS volume.

Note

If you want to store the files inside the EBS volume, you need to mount EBS volume to your Linux EC2 Instance.Manually.

Connect to Linux EC2 Instance through putty.

Mount an EBS Volume to your Linux EC2 Instance.

Switch to root user

Verify Available disks in your Linux Server

Verify the volume has any data by using the following command.

Format the volume to ext4 filesystem

Create a directory to mount our new ext4 volume (use any directory name you like)

Make Directory

Mount the volume to “ktexperts” directory

Verify the disk space in your Linux Server

Go to Mount Directory and verify files.

Make Files and Directories inside mount directory

EBS Automount on Reboot

By default on every reboot the  EBS volumes other than root volume will get unmounted.

To enable automount, you need to make an entry in the /etc/fstab file

Execute the following command to check id the fstab file has any error

Create Snapshot from EBS Volume

Go to Volumes,

Select your EBS Volume “My Linux” and click on Create Snapshot in the Actions.

Specify Description and value for the snapshot then click on Create Snapshot.

Create Snapshot Request Succeeded and Click on Close.

Go to snapshots, we can see  The snapshot has been created.

Create Volume from Snapshot

Before creating a volume we should know the Availability Zone of your Linux EC2 Instance.

Go to Instances,

Here we can see availability Zone of your Linux Ec2 Instance.

Go to Snapshots,

Select your created snapshot and click on Create Volume in the Actions.

Specify Availability Zone “Ap-South-1a” and value “My Linux (EBS – From Snapshot) then click on Create Volume.

We can see Create Volume Succeeded and click on Close.

The volume has been created from snapshot.

Launch Another Linux EC2 Instance

Please check below link to Launch Linux Server.

Launch Linux Server

we can see EC2 Linux Instance “My Linux 1” which was created earlier.

Verify volumes of your Linux Server.

Go volumes, we can see only one volumes attached to your Linux EC2 Volume.

It is the root volume.

Attach EBS Volume to your Another Linux EC2 Instance “My Linux 1”

Select your EBS Volume and click on Attach Volume in the Actions.

Select your required Linux EC2 Instance.

Click on Attach.

The EBS Volume has been attached to Second Linux EC2 Instance successfully.

Connect to Second Linux EC2 Instance through putty and verify files

Open Linux Terminal.

Switch to root user

Verify Available disks in your Linux Server

Verify the disk space in you Linux Instance

Verify the volume has any data by using the following command.

Create a directory to mount our new ext4 volume (use any directory name you like)

Make Directory

Mount the volume to “ktexperts” directory

Verify the disk space in you Linux Instance

Go to Mount Directory and verify files.

EBS Automount on Reboot

By default on every reboot the  EBS volumes other than root volume will get unmounted.

To enable automount, you need to make an entry in the /etc/fstab file

Execute the following command to check id the fstab file has any error

 

 

Thank you for giving your valuable time to read the above information.

Follow us on 

Website :  www.ktexperts.com

Facebook Page : KTexperts

Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment