Subject: Re: How can I detect USB device insertion/removal?
To: Scott Ellis <>
From: Werner Backes <>
List: current-users
Date: 07/12/2006 10:38:32
Scott Ellis wrote:

> My issue is, how can I programatically (or with a script) detect that 
> the new sd1 is connected (so I can mount it, kick off the backup, etc.)? 
>  Ideally, there'd be some event that gets fired when a device is 
> attached/detached that I could look for, rather than just polling 
> syslog. :-)

something like FreeBSD's usbd(8) would be helpful. In the meantime,
you could just write a simple program that polls /dev/usb for the
desired result. See section "USB EVENT INTERFACE" of the usb(4) man
page. It should be pretty easy to use.