How to auto-detect a USB drive?

Peter Steele psteele at maxiscale.com
Wed Mar 11 08:11:17 PDT 2009


>My question to you would be: What exactly do you mean by 
>"automatically detect"? The drive *is* automatically detected. 
>Should it be mounted afterwards? 

Yeah, I guess my wording was a little vague. I know that the system automatically detects when a USB drive is inserted, and creates the appropriate entries under /dev. I want to follow this up with having the drive automatically mounted, and I'll then examine the USB drive for specific files I expect to be present, and possible run something that's installed on the disk, then unmount the disk. We want to use this approach to deploy our software on large clusters of machines that may not have an IP identity. 

>You can use automounters to automatically mount devices when 
>they appear. In order how to determine file systems, slices 
>and partitions on such an USB device, you could, for example, 
>have a look at how FreeSBIE does it. 

If I can hook into an event that signals when a USB disk is inserted, I can take care of verifying the disk is in the format we expect it to be. 

>Additionally, there are already tools integrated in KDE and 
>Gnome that automount USB devices. 

Our boxes have no GUI so these may not work for us. We have a more specific application though and do not need a general purpose automounter. 

-- 
Polytropon 
>From Magdeburg, Germany 
Happy FreeBSD user since 4.0 
Andra moi ennepe, Mousa, ... 


More information about the freebsd-questions mailing list