removable devices auto umounting

Tijl Coosemans tijl at ulyssis.org
Fri Mar 21 08:21:27 PDT 2008


>> On Thu, Mar 20, 2008 at 11:55:32AM +1000, Da Rock wrote:
>>> I'm just looking into the removable device issue for freebsd. I can
>>> see its easy enough to auto mount a removable device (although I
>>> could use some help getting sd/xd devices working with my card
>>> reader), but the removal seems to come unstuck.
>>> 
>>> I have some barely literates on my systems, so I do need to work
>>> this out. Is it possible to use a forced umount to do this? What
>>> are the options here?

In KDE (same for GNOME and such I figure), removable devices like usb
keys, cameras, cd/dvd are automounted and appear on the desktop.
Using the right-click popup menu you can "Safely remove" or "Eject"
them.

For this to work, you need to have sysutils/hal installed and configure
x11/kdebase3 to enable hal support (this is the default).

Then you need to give users permission to access necessary devices.
It's best to create a separate group for that like plugdev and then
add users to this group. To give a plugdev group access to devices
create/edit the file /etc/devfs.rules to contain:

--- begin /etc/devfs.rules ---
[local_ruleset=10]
#allow plugdev to access the CAM subsystem (required for cd/dvd burning and usb mass storage)
add path xpt0 user root group plugdev mode 0660
add path 'pass*' user root group plugdev mode 0660
#only allow root for specific fixed SCSI drives if any
#add path pass0 user root group operator mode 0660
#add path pass1 user root group operator mode 0660
#...

#allow plugdev to access the cdrom
add path cd0 user root group plugdev mode 0660

#allow plugdev to access usb mass storage
add path 'da*' user root group plugdev mode 0660
#only allow root for specific fixed SCSI drives if any
#add path 'da0*' user root group operator mode 0660
#add path 'da1*' user root group operator mode 0660
#...

#allow plugdev to access generic usb devices (cameras/mp3 players using libusb)
add path 'usb*' user root group plugdev mode 0660
add path 'ugen*' user root group plugdev mode 0660
--- end /etc/devfs.rules ---

(You don't need anything special in /etc/devfs.conf. If you've put
stuff there to get cd burning working for normal users, you can
remove it. (permission for cd,xpt,pass devices))

In /etc/rc.conf then make sure you have these lines:

dbus_enable="YES"
devfs_system_ruleset="local_ruleset"
hald_enable="YES"
polkitd_enable="YES"

And finally, give plugdev access to hal by editing
/usr/local/etc/dbus-1/system.d/hal.conf
At the end of that file it says:

  <!-- You can change this to a more suitable user, or make per-group -->
  <policy group="operator">
    <allow send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
    <allow send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
    <allow send_interface="org.freedesktop.Hal.Device.Volume"/>
    <allow send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
  </policy>

On the second line above, change "operator" to "plugdev".

Then make sure you have a /var/media directory and /media linking to it
and nothing related to removable devices in /etc/fstab (including cdrom).
Reboot your system and if I didn't miss anything, any user in the
plugdev group should be able to use removable devices quite easily.


More information about the freebsd-questions mailing list