automount usb flash drive?

Roland Smith rsmith at xs4all.nl
Wed Apr 6 13:01:17 PDT 2005


On Wed, Apr 06, 2005 at 03:32:14PM -0400, Todd Shirk wrote:
> I was trying to figure out how to have a usb flash drive automount
> when I plug it in.  I currently have the following line in /etc/fstab
> 
> /dev/da0s1  /mnt/usbkey  msdos  rw,-m700,noauto  0  0
> 
> and the following in /etc/devfs.conf
> 
> perm  da0s1  0666

devfs.conf only works for devices available at boot time. For devices
you can plug in at runtime you should use /etc/devfs.rules:

[foobar=10]
add path 'da*s*' mode 0666

And you should have the following in /etc/rc.conf:

devfs_system_ruleset="foobar"

The contents of devfs.rules are fed to devfs(8), so see it's manual page.

> when I do the following command line command the usb flash drive mount fine
> 
> # mount /mnt/usbkey
> 
> But, when I'm in KDE viewing media:/  Removable Device (da0s1) is
> shown is unmounted.
> 
> At the user level command line and in KDE, I receive /dev/da0s1:
> Operation not permitted.

For a user to be able to use a filesystem, there are a couple of things
that need to be done:
- The sysctl variable vfs.usermount must be set to 1 (in /etc/sysctl.conf).
- The user in question must own the mount point.

> I'm not sure if part of the issue is permissions or if I'm missing a
> piece for the auto-mounting to happen.

I think the latter. Normally usbd(8) is notified of USB events, but in
this case it seems to get events for the umass* device, not the da*s*
device that you'll want to use. There have been people who've used a
shell-script called by usbd to figure out the connection between
umass<->da from dmesg output and then mount the filesystem, but that
doesn't do umounts. It's also complicated if you want it to work for
multiple users, unless you give it 777 permissions. You could also give
amd(8) a try.

I found that making a one-line shell script to do the mounting is much
less hassle.

Roland
-- 
R.F. Smith                           /"\    ASCII Ribbon Campaign
r s m i t h @ x s 4 a l l . n l      \ /    No HTML/RTF in e-mail
http://www.xs4all.nl/~rsmith/         X     No Word docs in e-mail
public key: http://www.keyserver.net / \    Respect for open standards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050406/ce15c45c/attachment.bin


More information about the freebsd-questions mailing list