You are here

Using new EBS volume with your Amazon AWS instance server

So you just decided to create a new EBS volume to be used with one of your Amazon AWS Instances. Why would you do this? I could think of many reasons, but the one for me is using it as a repository for my git files, so they are preserved in case my instance is shut down or corrupt.
To do this, follow the steps below:

  1. Create the EBS Volume:
  2. Go to your AWS Management Console, choose your region and find the "Elastic Block Stores"(EBS) / Volumes option.

  3. Click on the "Create Volume"Button
  4. and choose a name and add the tags in case you need and use them.

  5. Click on the "Attach Volume"Button
  6. and select the instance you want this volume to be attached to.

  7. Connect to your instance server to format the new EBS Volume
  8. Type $ sudo fdisk -l to see a list of all the volumes.
  9. The new volume should be there. In my case it is called /dev/xvdf.

  10. Format with $ sudo mkfs -t ext4 /dev/xvdf.
  11. Edit the fstab file with $ sudo vi /etc/fstab
  12. Add this to the end of the file:
  13. /dev/xvdf /mnt/repo ext4 defaults,noatime 0 0

  14. Mount the drive by running $ mount /mnt/repo
  15. Test the mount by running$ df -ak

  16. Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/xvda1 8256952 986580 7186504 13% /
    tmpfs 308520 0 308520 0% /dev/shm
    /dev/xvdf 1032088 34052 945608 4% /mnt/repo