Mounting EBS volume in EC2

Refer http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html for detailed instructions.

  1. Create a volume in EBS screen
  2. Attach it to your desired EC2 instance
  3. From the command line issue the following commands
    1. lsblk – to know the device name
    2. sudo file -s /dev/xvdf  (if it says “data” thats good to go)
    3. sudo mkfs -t ext4 /dev/xvdf (format the new volume)
    4. sudo mkdir /my_data (new folder to mount into)
    5. sudo mount /dev/xvdf /my_data

In case you have expanded the volume size to a bigger value, give the commands below (Refer http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html?icmpid=docs_ec2_console)

Note: After modifying the size, AWS optimizes the space and the new space will not be available for some time. Make sure that the expanded volume status is changed to “available – completed (100%)

  • df -h
  • sudo resize2fs /dev/xvdf
  • df -h
error: Uh oh ...