Is it safe to mount an EBS drive at /mnt/some_name and reboot the EC2 instance

amazon ec2amazon-ebsamazon-web-services

From what I've seen online everyone seems to mount additional EBS drives at /mnt/some_name. However /mnt is the mount point of the instance's ephemeral storage and this gets lost when the instance is stopped.

Assuming I've added the right entry in /etc/fstab can I reboot or stop/start the instance and have the drive still mounted?

My thinking is that the mount point /mnt/some_name will be lost during the reboot so the drive will not be able to be mounted. Am I right? Where should I mount things then?

Best Answer

Unsatisfied that my question has been understood properly, I've run the experiment for myself. The outcome is that...

Yes, on stop/start everything under /mnt is lost and you can't mount the drive without recreating the mount point. As I expected, but...

If you add an entry to /etc/fstab it doen't matter that the mount point doesn't exist, it will be created and the drive mounted.

  • Create new small instance, an extra EBS and a filesystem on it.
  • Create a directory at /mnt/test, inside the ephemeral storage.
  • sudo mount /dev/xvdf /mnt/test - Fine.
  • Reboot
  • /mnt/test exists.
  • sudo mount /dev/xvdf /mnt/test - Fine.
  • Stop Instance
  • Start Instance
  • /mnt/test does not exist
  • sudo mount /dev/xvdf /mnt/test - Error: mount point /mnt/test does not exist
  • Recreate dir, remount drive, add to /etc/fstab
  • Stop Instance
  • Start Instance
  • /mnt/test exists, EBS mounted, testfile exists

I haven't tested how deep this autocreation goes. If I mount at /mnt/a/b/c would it still work?