Contributed by jcr on from the not-allowed-to-make-mount-jokes dept.
Alexey Vatchenko (av<at>bsdua<dot>org) wrote in to tell us about his hotplug-diskmount port for automated disk mounting.
The hotplug-diskmount port is a plug-in for the OpenBSD hotplugd(8) daemon to automatically mount removable disks to the filesystem. It works with any disk types (SD cards, USB mass storage devices, card readers and CD/DVD drives). The hotplug-diskmount program is intended to be used in single user environment on desktop or laptop where the convenience of automatic mounting is really helpful.
Configuring
First of all, you want to initialize hotplug-diskmount so it creates the directories where all mount points will be placed. By default it creates the "/vol" directory and automatically creates subdirectories under it as mount points based on the drive name (label).
# /usr/local/libexec/hotplug-diskmount initEnable hotplugd(8) so it starts at boot time.
# echo "hotplugd_flags=\"\"" >> /etc/rc.conf.localYou'll need to either create or add to your "/etc/hotplug/attach" script and remember to set executable bit. The following is a very simple example script.
#!/bin/sh DEVCLASS=$1 DEVNAME=$2 case $DEVCLASS in 2) /usr/local/libexec/hotplug-diskmount attach "$DEVNAME" ;; esacTo get it running, either start or restart hotplugd(8) and hotplug-diskmount will be enabled.
# /etc/rc.d/hotplugd restartBy default hotplug-diskmount will mount the disk as the "root" user and "wheel" group with chmod mode permissions set to 0755. These can be changed with the "-u" "-g" and "-m" flags (or the "-r" flag if you want read-only) in your "/etc/hotplug/attach" script. Also by default, hotplug-diskmount will always run fsck(8) before mounting the file systems, but you can control this behavior with the "-f" flag.
What You Get
When you insert a USB thumb drive, SD card, CD/DVD, or similar disk device, all of the file systems on the device will be automatically mounted under "/vol/DRIVE_NAME" and the name is based on the label of the disk. For example, the following shows you the label of the CDROM for most recent OpenBSD snapshot:
$ /sbin/disklabel cd0 2>&1 | sed -n '/^label: /s/^label: //p' 5.4 Install CDIf you're still running OpenBSD 5.3 you might want to note that a new version of hotplug-diskmount is available even though it's not in the 5.3 ports tree. The newest 0.8 version is already available in the post-5.4 snapshots ports tree.
If you want to contribute to hotplug-diskmount, there is a page for recent hotplug-diskmount announcements and the public mecurial repository is here:
$ hg clone https://bitbucket.org/alex_vatchenko/hotplug-diskmount
(Comments are closed)
By Morgan (92.103.142.226) on
Thanks !
Comments
By Alex Vatchenko (92.113.6.133) av@bsdua.org on www.bsdua.org
I wrote graphical tool to unmount devices:
http://www.bsdua.org/tray-app.html
> are the directories in "/vol" deleted when the device is unplugged ?
yes.
Comments
By Morgan (62.35.248.148) on
>
> I wrote graphical tool to unmount devices:
> http://www.bsdua.org/tray-app.html
>
> > are the directories in "/vol" deleted when the device is unplugged ?
>
> yes.
Thanks a lot
By Anonymous Coward (37.162.169.97) on
The advantage of Toad is that it follows the udev path hierarchy and file managers automatically pick up the newly inserted device. Plug in the device and see i.e. Thunar pop up automatically. It also automounts CDs. The disadvantage is that it depends on ugly stuff like consolekit etc.
By Zé Loff (81.193.33.144) zeloff@zeloff.org on
I have full disk encryption, so I ended up with a bunch of "/vol/SR CRYPTO" folders, although only one of them was mounted (the root fs). Nothing a small 'if [ $DEVNAME != "foo" ]' couldn't fix.
Anyway, thanks for the tool!
Cheers
Zé