bsdua.org

/projects/hotplug-diskmount

Hotplug-diskmount is a plug-in to OpenBSD's hotplugd that automatically mounts removable disks to the filesystem. It works with any disk types (SD cards, USB mass storage devices, card readers and CD/DVD drives). This program is indended to be used in single user environment on desktop or laptop.

Before use

First of all, create directory where all mountpoints will be placed. Pay attention, that .db directory must be secured.

# mkdir /vol
# mkdir /vol/.db
# chmod 700 /vol/.db

Enable hotplugd at boot time.

# echo "hotplugd_flags=\"\"" >> /etc/rc.conf.local

Add missing parts to your /etc/hotplug/attach. Remember to set executable bit to attach script if you are creating new one.

#!/bin/sh

DEVCLASS=$1
DEVNAME=$2

case $DEVCLASS in
2)
        /usr/local/libexec/hotplug-diskmount attach -u av -m 700 "$DEVNAME"
        ;;
esac

What you get

When you plug USB thumb drive, insert SD card into the attached card reader or insert CD/DVD into attached removable DVD drive filesystems from these devices will be automatically mounted under /vol/DRIVE_NAME. Hotplug-diskmount will mount as many partitions as disk contains.
$ mount 
/dev/sd0i on /vol/CANON_SD32 type msdos (local, nodev, nosuid)
/dev/cd0a on /vol/4.7 Install CD type cd9660 (local, nodev, ...

$ ls /vol
4.7 Install CD  CANON_SD32

Download:

Ukrainian OpenBSD User Group
Get Firefox

Copyright © 2006-2010, Alexey Vatchenko. All rights reserved.
Designed by Vladimir Mostovoy.