You are here
EBSmount: Automatically mount EBS devices on Amazon EC2
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
ImportError: cannot import name ExecError
Hi
I'm really keen to use ebsmount on my Centos5 instances, but when I try and run ebsmount-manual, I get the error
ebsmount-manual --format=ext3 /dev/sdh
Traceback (most recent call last):
File "/usr/local/bin/ebsmount-manual", line 19, in ?
import ebsmount
File "/usr/local/lib/ebsmount/ebsmount.py", line 6, in ?
import udevdb
File "/usr/local/lib/ebsmount/udevdb.py", line 7, in ?
from executil import ExecError, getoutput
ImportError: cannot import name ExecError
I've had a search on Google and can't find any reference to ExecError. Can you tell me how to resolve this error
Thanks
Rob
EBSmount depends on turnkey-pylib
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.
Another approach to mount on boot
In Fedora AMI to automatically mount EBS volume on a reboot:
After creating EBS volume and attaching to the AMI using the AWS console I just:
(substitute as appropriate)
mkdir /backups
mount /dev/sdf /backups
worked!!
Thanks!!
Nice - thanks a lot.
Nice - thanks a lot.
Mounting from multiple AMIs
Hey, we are looking for a solution that will allow us to create an AMI that acts as a file server and mount to the file server with multiple AMIs. I just want to make sure that I am reading this correctly and that this would be a possible solution.
The use case here is that we have an AMI with an attached EBS that we would then like to mount from the EBS to another AMI with an attached EBS.
mount ami
Hi,
I just did that with nfs. The only gotchas I came across was make sure to open the appropriate ports for your security group and specify the right ips in your /etc/exports.
Best of luck.
MD
I found the following helpful
I found the following helpful tip at this URL:
http://www.turnkeylinux.org/forum/support/20100814/ebs-and-ec2
For easy access to your EBS I would recommend creating a symlink, something like this:
Then, you can simply "cd /vol".
I hope the above helps.
This might sound like a
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
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."
No, it doesn't partition the disk...
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...
Thanks Alon for the quick
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.
Nope, no downside
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.
Set Up on other AMI instances?
This will probably be seen as a really bad question, but how do I get this installed? I'm just getting started with learning using one of the suse preinstalled AMI's from AWS. I'm not a linux guy at all, I am learning as I go.
I have
Downloaded turnkey-pylib - https://github.com/turnkeylinux/turnkey-pylib
Downloaded ebsmount - https://github.com/turnkeylinux/ebsmount
copied each of those to their own directory on my instance and extracted the archive via ssh putty.
I managed to get the turkey-pylib installed by reading the INSTALL file and running python setup.py install
I can't figure out how to install ebsmount after looking through the files & the web
Can you help a brother out? Thank you!
Use TurnKey!
MOUNTDIR
I believe I have it working, Am I right in thinking I just need to modify ebsmount.conf and change the MOUNTDIR to where I want the volume to be mounted?
I'll have to try out turnkey soon.
All interesting... Is there any "documentation" on this?
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!
Why is there no date on this page?
Seriously? No indication of how old this is on the page, nothing in the URL.
Logs data path for Mounted partitions in EC2
Hi,
How can I see when my ebs volume has got dettached and attached, where can i get information
Pages
Add new comment