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.
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 init
Enable hotplugd(8) so it starts at boot time.# echo "hotplugd_flags=\"\"" >> /etc/rc.conf.local
You'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" ;; esac
To get it running, either start or restart hotplugd(8) and hotplug-diskmount will be enabled.# /etc/rc.d/hotplugd restart
By 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 CD
If 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)