๐น PART 1: Create EC2 Instance + Custom EBS Volume
Step 1: Launch EC2 Instance
-
Go to AWS Console โ EC2
-
Click Launch Instance
-
Configure:
-
Name:
ec2-nishan -
AMI: Amazon Linux (or Ubuntu)
-
Instance type: t2.micro (free tier)
-
Key pair: create/download
.pem -
Network:
- VPC: Default VPC
- Subnet: Default subnet (AZ1)
-
Important: Note the Availability Zone (AZ) (e.g., ap-south-1a)
You will need the SAME AZ for EBS.
- Launch instance
Step 2: Check EC2 Availability Zone
- Go to Instances โ select your EC2
- Check Availability Zone (e.g.,
ap-south-1a)
Step 3: Connect to EC2 (SSH)
ssh -i your-key.pem ec2-user@your-public-ip
Step 4: Check Existing Disks
lsblk
๐น PART 2: Create and Attach EBS Volume
Step 5: Create EBS Volume
-
Go to EC2 โ Elastic Block Store โ Volumes
-
Click Create Volume
-
Configure:
- Name:
ebs-volume1-nishan - Size: e.g., 8 GB
- AZ: Same as EC2 (VERY IMPORTANT)
- Name:
-
Click Create Volume
Step 6: Attach Volume to EC2
-
Select your volume
-
Click Actions โ Attach Volume
-
Choose your EC2 instance
-
Device name:
/dev/sdk -
Attach
Step 7: Verify in EC2
lsblk
Youโll see something like:
nvme1n1
Step 8: Check if Volume is Empty
sudo file -s /dev/nvme1n1
If output shows data, it means no filesystem yet.
Step 9: Create File System
sudo mkfs -t xfs /dev/nvme1n1
Step 10: Create Mount Directory
sudo mkdir /myebsvolume1
Step 11: Mount the Volume
sudo mount /dev/nvme1n1 /myebsvolume1
Step 12: Verify
ls -lart /myebsvolume1
df -h
Take screenshot till here (your requirement)
๐น PART 3: Increase Volume Size
Step 13: Modify Volume
- Go to Volumes
- Select your volume
- Click Actions โ Modify Volume
- Increase size (e.g., 8GB โ 12GB)
Step 14: Verify in EC2
sudo fdisk -l
(Optional for full usage)
sudo xfs_growfs /myebsvolume1
๐น PART 4: Create Snapshot
Step 15: Create Snapshot
-
Go to Volumes
-
Select your volume
-
Click: Actions โ Create Snapshot
-
Give:
- Name
- Description
-
Click Create Snapshot
๐น PART 5: Create New Volume from Snapshot
Step 16:
- Go to Snapshots
- Select your snapshot
- Click: Actions โ Create Volume
- Keep same configuration
- Create volume
Step 17:
- Copy new volume ID
- Rename it (optional)
๐น PART 6: Attach Snapshot Volume to NEW EC2
Step 18: Launch Second EC2
-
Same steps as before
-
Ensure:
- SAME AZ as volume
Step 19: Attach Volume
- Go to Volumes
- Select new volume
- Click: Actions โ Attach Volume
- Attach to second EC2
๐น PART 7: Access Volume in Second EC2
Step 20: SSH into second EC2
ssh -i your-key.pem ec2-user@public-ip
Step 21: Check Disks
lsblk
Step 22: Create Mount Directory
sudo mkdir /myebsvolume2
Step 23: Mount Volume
sudo mount /dev/nvme1n1 /myebsvolume2
Step 24: Verify Data
ls -lart /myebsvolume2
You should see same data from snapshot