AWS EBS Contd
Activity 1: Mount the ebs volume to /tools in ec2 (linux flavored)
- Create an ec2 instance with ubuntu os
- for partitions Refer Here
- Attach an ebs volume to ec2
- Refer Here for linux file systems
- Create a filesystem for volume
sudo mkfs -t xfs /dev/xvdf
* Make a note of block id by executing sudo blkid
/dev/xvdf: UUID="4236cfcf-c889-447b-a3b5-f851e60436c9" BLOCK_SIZE="512" TYPE="xfs"
- Now lets mount the disk to the tools folder
sudo mkdir /tools
sudo mount /dev/xvdf /tools
- list the mounts
- now lets create some files in /tools
sudo touch /tools/1.txt
Actvity 2: Ensure mounts persist across restarts
- stop the ec2 instance and start again
- ssh into ec2 instance and execute
ls /tools
- list the mounts
sudo df -h
* To ensure your ec2 instance retains mounts we need to add entries into /etc/fstab
* add the following entry into fstab and stop and start the ec2 instance
UUID=4236cfcf-c889-447b-a3b5-f851e60436c9 /tools xfs defaults,nofail 1 2
ls /tools
- list the mounts
sudo df -h
Activity 3: EBS Snapshots
- Backup of EBS is called EBS snapshot
- EBS volume will be available in a zone, where as snapshot is available in a region
- Create a snapshot
- From snapshot we create recreate an ebs volume
- Using the snapshot we can create the volume in any az in same region
- We can copy the snapshot to any region and create a disk there
- Once the snapshot is copied, create an ebs volume in any zone and attach to ec2
- Lets automate the snapshot creation
Activity 4
- Create an ec2 instance in one region A (us-west-2 oregon)
- Create an ec2 instance in other region B (ap-south-1 mumbai)
- In an ec2 instance in region A, Attach an ebs volume of type gp2 and size 1 GiB.
- mount the volume to /projects folder
- now create some files in /projects
- create a snapshot, copy the snapshot to region B and attach the disk created from this snapshot to ec2 instance in Region B
