Attaching AWS EBS VOLUME TO AMAZON EC2

 Attaching AWS EBS VOLUME TO AMAZON EC2:

Procedure:

  1. Open AWS Console.
  2. Click the Volume section within AWS console under the EC2 dashboard.
  3. Select the EBS Volume that you want to attach to an EC2 instance. The EBS volume should be in available status.
  4. Enter the Instance ID or the Instance name. Make sure that the Amazon EBS volume and the Amazon EC2 instance are in the same availability zone.
  5. After attaching the volume, you will be able to see identical block devices for an EC2 instance.
  6. Congratulations  ! You have successfully attached the Amazon EBS volume to an Instance. Now you need to ssh to the instance and mount the device to a mount directory.
  7. How To Mount EBS VolumeLog in to an instance through ssh and list the disk attached to the instance by using the command: fdisk -l
  8. Depending on the block device or driver of the kernel, the device might be attached with a different name than what you specified. For example, if we specify a device name of /dev/sdf, our device might be renamed /dev/xvdf by the kernel. In most cases, the trailing letter remains the same.
  9. List the block device by using the command: lsblk
  10. Check the file system on the attached volume: file -s /dev/xvdf
  11. EBS volumes restored from snapshots often have a file system on them already. If it’s not a new volume, we need to create a file system for them before we can mount them. We can do this by using: mkfs.ext4 /dev/xvdf
  12. Create a mount directory where you want to mount the device: mkdir /mountdir
  13. Open the /etc/fstab file and add a new line at the end of file, as demonstrated in the screenshot below. Adding this entry is important. This will make sure even after rebooting the instance directory, mounting will begin.device_name  mount_point  file_system_type  fs_mntops  fs_freq  fs_passn /dev/xvdf   /mountdir  ext4      defaults, nofail     0     2
  14. Run below-mentioned mount command to mount all of the filesystems in /etc/fstab file. mount -a
  15. Check the disk’s free space by using the command below df -h
  16. You must unmount the volume before you detach it.
  17. If the EBS volume is inside the root device of an instance then you must stop the original EC2 instance before detaching the volume.
  18. Make sure that the EBS volume and new instances  the same availability zone.
  19. Volumes that have been restored from snapshots, or have already been attached to an instance, likely have a file system on them. if you create a new file system on the top of an existing file system, the operation overwrites your data. So, only in the case of a new volume, should you create a file system









Comments

Popular posts from this blog

VPC in AWS