# Automounting usb flash devices



## spork (Apr 25, 2011)

Howdy,

I'm looking to find the current best practice on automounting usb flash devices when not using a DE like Gnome or KDE - this is a server.  In my many years of working with FreeBSD I've never touched amd and these days I'm not even sure that's the best choice.  I see there's "hald" which seems to be associated more with Gnome or KDE, perhaps that's the right answer.  Anyhow, this is what I'm looking for:

-ability to identify a specific usb flash device and mount it, ignoring any other devices that might get plugged in
-when mounted, be able to trigger a script
-when unmounted (by the script), don't re-mount it for any crazy reason

Any pointers?


----------



## SirDice (Apr 25, 2011)

spork said:
			
		

> I see there's "hald" which seems to be associated more with Gnome or KDE, perhaps that's the right answer.


Not anymore it isn't, and it probably never was  
Both the new Gnome and XFCE have dropped automounting using HAL and implemented it using udev. 
Which basically means automounting doesn't work on FreeBSD with the latest Gnome and XFCE


----------



## wblock@ (Apr 25, 2011)

hal is not required.  Never was, really, but it was handy.

It depends on how you want to identify a specific USB device.  amd(8) might be appropriate.
devd(8) is probably more work, but more capable.  I posted an example of using devd and a script in the "How to make devd automount USB storage devices?" thread.  That could be changed to look for a specific filesystem label or even just USB vendor/product IDs.


----------



## spork (Apr 25, 2011)

wblock: Thanks!  That will suit my needs perfectly.

SirDice: What a shame.  That kind of stuff really bugs me.  Inserting Linuxisms into projects that need not be linux-only seems hypocritical at best given how many linux evangelists are inclined to jump all over MS and Apple for being "proprietary".


----------



## aragon (Apr 27, 2011)

Spork, take a look at my xmountd script, in particular the /tmp/.xmountd/mountable file that it maintains.  It should be trivial to write another shell script that parses that file looking for file systems to mount/umount.


----------

