Skip to content
TURNKEYGNU / LINUX
AppsDocumentationBlogScreenshotsGitHubTurnKey Hub
文English
EnglishDeutschEspañol日本語Português中文
Home/Blog/EBSmount: Automatically mount EBS devices on Amazon EC2

From the project

EBSmount: Automatically mount EBS devices on Amazon EC2

By Alon SwartzApril 15, 20104 min read
awsec2cloud

The 2 most annoying things about Amazon EBS (Elastic Block Storage) I have found, is that there is no support to auto-attach an EBS on instance launch, and the need to manually mount an EBS when it's attached.

If the above annoys you as well, you're in luck! The first annoyance has been solved in the TurnKey Hub (private beta soon to be announced - request an invite here), and the second, well, is solved by EBSmount.

EBSmount is pre-installed on all the latest TurnKey AMI's, but should work without issue on any Ubuntu/Debian based system, or any other distribution that uses udev (with minor tweaks). The source code has been released on github, and the package is available in the TurnKey package archive.

Enough said, lets get to it.

EBSmount has 2 commands

ebsmount-udev       Triggered by udev on EBS attach and detach
ebsmount-manual     Manually mount EBS device (simulates udev add trigger)

Features

  • Automatically mounts EBS devices when they are attached (via udev)
  • Supports formatted devices, as well as partitions
  • Ignores unformatted devices and unsupported filesystems
  • Device/partition uniquely identifiable mountpoints
  • Configurable mount options
  • Hooking scripts execution upon mount
  • Convenience command for a one step format and mount
  • Logging

Quick start

If the EBS device is not formatted, it will not be mounted automatically. For convenience, you can format and mount the device in one step, for example:

ebsmount-manual --format=ext3 /dev/sdf

Default configuration


/etc/ebsmount.conf

ENABLED=True
MOUNTDIR=/media/ebs
MOUNTOPTIONS=noatime
FILESYSTEMS=ext2 ext3
LOGFILE=/var/log/ebsmount.log

Unique mountpoints

Every EBS filesystem is mounted to its own uniquely identifiable mountpoint, based on:

$(MOUNTDIR)/$(basename PHYSDEVPATH)/$(FS_UUID)[:4]

For example:

/media/ebs/vbd-2160/a1b2

Hooking scripts

Once a filesystem is mounted, EBSmount will execute scripts located in MOUNTPOINT/.ebsmount in alpha-numeric ordering.

This provides a very powerful mechanism. In its simplest form, the user might want to symlink the mountpoint to a more accessible path, for example:


MOUNTPOINT/.ebsmount/10symlink

#!/bin/bash -e
target=/vol
mountp=$(dirname $(dirname $0))
[ ! -h $target ] && ln -s $mountp $target

Comments (8)

EBSmount depends on turnkey-pylib

Reply 1 2010-06-09

EBSmount depends on turnkey-pylib, which provides the python module executil (as well as conffile). It is available as a deb package, and you can find the source code here.

Hope the above helps.

I found the following helpful

Reply 2 2011-01-05

I found the following helpful tip at this URL:
/forum/support/20100814/ebs-and-ec2

 

For easy access to your EBS I would recommend creating a symlink, something like this:

ln -s /media/ebs/vbd-2160/a1b2 /vol

Then, you can simply "cd /vol".

I hope the above helps.

Nope, no downside

Reply 3 2011-01-06

Nope, no downside, actually to the contrary, it's simpler and less error prone, so I'd recommend it. All our EBS's are formatted without partitions and are working great. 

Thanks Alon for the quick

Reply 4 2011-01-05

Thanks Alon for the quick reply.

Is there any downside to not partitioning? 

I had inadvertantly left out the partitioning step by the way.  In fact, I didn't know that you could format a drive without partitioning it.

No, it doesn't partition the disk...

Reply 5 2011-01-05

No, it doesn't partition the disk. It just accepts the device you want to format/mount and does it's stuff. So in your case the full volume is being used -which is fine, and generally the way EBS volumes are used.

There isn't much point in partitioning an EBS device anyway, if you want another volume just create it. That is unless if you want to use RAID or LVM, but thats a whole other story...

This might sound like a

Reply 6 2011-01-05

This might sound like a stupid question, but I did not partition the EBS volume after I attached it to my turnkey appliance.

I then ran

ebsmount-manual --format=ext3 /dev/sdf

So basically, I formatted without partitioning.

I can see the volume and I have data there.  By chance, does the command partition the drive when it does the formatting?

If I go into Webmin and look at "Partitions on local disks" it says "This disk has no partitions yet."

Use TurnKey!

Reply 7 2011-04-12
If you launch a TurnKey instance from the Hub it comes with ebsmount preinstalled. Installing on SUSE is probably possible if you know what you're doing but otherwise, it's touch and go.

All interesting... Is there any "documentation" on this?

Reply 8 2011-04-23

I could see a real advantage in having "shared" access to one Network Drive between TKL Image installs..  Also, potentially the same for MySQL and/or even Windows systems looking at the same Drives so some databridges could be simplified (FoxPro to MySQL for instance).

Keep it up.   The landscape is changing fast. 

I should ask, what do we do if Alon and/or Liraz need to exit to something "bigger or better paying"?  I would hate to see this all go away.  It is really incredible the systems you have built with the bigger team!

Keep exploring

Find your next server

Browse ready-to-use appliances by the job you need to do.

Explore the app library
TURNKEYGNU / LINUX

Own your infrastructure without starting from scratch.

Explore TurnKey
AboutDocumentationFAQBlogGitHub
Free and open sourceSecure by defaultReady to deploy