automount external usb hard drive?

Daniel Bye freebsd-questions at
Tue Feb 14 17:59:23 PST 2006

On Tue, Feb 14, 2006 at 08:01:44PM -0500, Peter wrote:
> Hi, is it possible to have an external USB hard drive automounted once
> connected?  

It certainly is - you need to create a hook for for your device in
/etc/usbd.conf.  To find out the required details, run usbd from the
command line:

 # /etc/rc.d/usbd stop
 # usbd -dv

Connect your device, and take a note of the values for the device-attach
event.  For example, this is what I get when connecting a Disgo Lite USB
key drive.

usbd: device-attach event at 1139967116.311696000, disgo, vendor 0x08ec:
  vndr=0x08ec prdct=0x0008 rlse=0x0100 clss=0x0000 subclss=0x0000 prtcl=0x0000
  device names: umass0

This is what the corresponding entry in /etc/usbd.conf looks like:

device "Disgo Lite USB Key"
       devname "umass[0-9]+"
       vendor 0x08ec
       product 0x0008
       release 0x0100
       attach "sleep 3; mount -t msdosfs /dev/`camcontrol devlist | awk
'/disgo/ {print $NF}' | sed -e 's/(\(.*\))/\1s1/'` /mnt/disgo"

Note the "attach" command must be one continuous line - you can't break
up long commands to prettify the file.  The attach command here works for 
me - you might need something else, depending on your specific 
requirements.  For example, if you regularly attach more than one
storage device, you will certainly want a smarter way of handling them!

Of course, you will need to make sure you explicitly unmount the file
system before detaching the device.

man usbd, man usbd.conf and man camcontrol for more details.


Daniel Bye

PGP Key:
PGP Key fingerprint: 3B9D 8BBB EB03 BA83 5DB4 3B88 86FC F03A 90A1 BE8F
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list