This particular instance type mounts two ephemeral drives, in /dev/ and /mnt/. I have to create working directories for one of my services in these paths at startup or the services won't launch. Sometimes the script below works, sometimes it does not. I suspect it's a race between the folder being mounted, and my rc.local script kicking off.

Is there a more reliable place I can create these directories? The last time I booted up, the /mnt/mongodb dir did get created, but the /dev/ one did not. I'm running the 12.04 HVM ubuntu instance from amazon.

Here is my rc.local file:

cd /mnt/
sudo mkdir mongodb
sudo chown -R mongodb mongodb
sudo chgrp -R mongodb mongodb
cd /dev/
sudo mkdir mongodb
sudo chown -R mongodb mongodb
sudo chgrp -R mongodb mongodb
sudo service mongodb start
exit 0
  • 1
    What is it that mounts the directories? – terdon Oct 28 '13 at 16:48
  • I'm not sure, because these are ephemeral drives that amazon mounts on launch, I'm sure I can find it, but I'm not sure where to look. – Tom Swifty Oct 28 '13 at 17:06
  • Well, you could just add a test in your rc.local that will only create the directory if the volume is mounted. That will make you system wait until they have been mounted. – terdon Oct 28 '13 at 17:14

I believe it is the cloud-init package that automatically mounts the first ephemeral disc as /mnt. /dev should be just for devices. So the first ephemeral disc (or instance store) will be exposed as /dev/sdb (or /dev/xvdb) and them mounted as /mnt. If you provide your script as instance user data, i.e. use the cloud-init system, then it will be run after the cloud-init system has created the mount. Alternatively, you need to set its order so it runs after cloud-init. Or you could beat cloud-init to it and create the mount yourself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.