How to auto-detect a USB drive?

Peter Steele psteele at
Thu Mar 12 10:43:59 PDT 2009

>I do something like this. Here's the rules I have 
>in /usr/local/etc/devd.conf 
> attach 10 { 
> match "device-name" "umass0"; 
> action "sleep 2; /root/bin/usbstick_attach > /dev/console"; 

I've tried something similar and I'm having good success. I should be able accomplish what I need with this approach. 

One question: Is there a way to check the label of a device before mounting it? I assume so, since when I insert a FAT32 formatted USB stick I see the messages: 

Mar 12 10:29:05 r02s17 kernel: GEOM_LABEL: Label for provider da0s1 is msdosfs/MAXIFS. 
Mar 12 10:29:06 r02s17 kernel: GEOM_LABEL: Label msdosfs/MAXIFS removed. 

Can I easily get this same information? 

More information about the freebsd-questions mailing list