LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-19-2009, 01:03 AM   #1
mike11
Member
 
Registered: Apr 2009
Posts: 222

Rep: Reputation: 17
how to automount usb drives with user owner and user r/w permissions


I've installed usbmount to auto-mount usb pen drives. This works OK but they're mounted with owner root and root r/w permissions.
Searching online people have mentioned modifying HAL and udev rules.
Can someone please explain what exactly I need to do?

cat /usr/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<deviceinfo version="0.2">
  <device>
    <match key="info.udi" string="/org/freedesktop/Hal/devices/computer">
      <append key="info.callouts.add" type="strlist">hal-storage-cleanup-all-mountpoints</append>
    </match>

    <!-- poll drives with removable media -->
    <match key="storage.removable" bool="true">
      <append key="info.addons" type="strlist">hald-addon-storage</append>
    </match>

    <match key="volume.is_disc" bool="true">
      <match key="volume.disc.has_audio" bool="true">
        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>
      </match>
      <match key="volume.disc.is_blank" bool="true">
        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>
      </match>
    </match>

    <!-- this is to be able to mount media in drives we cannot poll, e.g. IDE Zip Drives and PC style floppy drives -->
    <match key="storage.media_check_enabled" bool="false">
      <match key="storage.no_partitions_hint" bool="true">

        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>

        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Mount</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">ssas</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">mount_point fstype extra_options</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-mount</append>

        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Unmount</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-unmount</append>

        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>

        <!-- allow these mount options for all file systems -->
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
          <append key="volume.mount.valid_options" type="strlist">ro</append>
          <append key="volume.mount.valid_options" type="strlist">sync</append>
          <append key="volume.mount.valid_options" type="strlist">dirsync</append>
          <append key="volume.mount.valid_options" type="strlist">noatime</append>
          <append key="volume.mount.valid_options" type="strlist">nodiratime</append>
          <append key="volume.mount.valid_options" type="strlist">relatime</append>
          <append key="volume.mount.valid_options" type="strlist">noexec</append>
          <append key="volume.mount.valid_options" type="strlist">quiet</append>
          <append key="volume.mount.valid_options" type="strlist">remount</append>
	  <append key="volume.mount.valid_options" type="strlist">exec</append>
          <!-- As this is removable media give some leeway -->
	  <append key="volume.mount.valid_options" type="strlist">utf8</append>
	  <append key="volume.mount.valid_options" type="strlist">shortname=</append>
	  <append key="volume.mount.valid_options" type="strlist">codepage=</append>
	  <append key="volume.mount.valid_options" type="strlist">iocharset=</append>
	  <append key="volume.mount.valid_options" type="strlist">umask=</append>
	  <append key="volume.mount.valid_options" type="strlist">uid=</append>
	</match>
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
	  <append key="volume.mount.valid_options" type="strlist">ro</append>
	  <append key="volume.mount.valid_options" type="strlist">noexec</append>
	  <append key="volume.mount.valid_options" type="strlist">noatime</append>
	</match>
      </match>
    </match>


    <match key="volume.fsusage" string="filesystem">

      <!-- Here follow volumes we specifically want to ignore - it is the -->
      <!-- responsibility of software higher in the stack (e.g. gnome-vfs) -->
      <!-- amd mount programs (e.g. Mount() on HAL) to respect volume.ignore -->
      <merge key="volume.ignore" type="bool">false</merge>

      <!-- Should always ignore Apple Bootstrap partitions (it would be -->
      <!-- a security hole to mount it) - TODO: should use the bootable -->
      <!-- flag from the Mac partition table instead -->
      <match key="volume.fstype" string="hfs">
	<match key="volume.label" string="bootstrap">
          <merge key="volume.ignore" type="bool">true</merge>
	</match>
      </match>

      <!-- EFI firmware partitions -->
      <match key="volume.fstype" string="vfat">
	<match key="volume.label" string="EFI">
	  <merge key="volume.ignore" type="bool">true</merge>
	</match>
      </match>

      <match key="volume.fstype" string_outof="ntfs;vfat">
        <match key="volume.label" string="RECOVERY">
          <merge key="volume.ignore" type="bool">true</merge>
        </match>
        <!-- ASUS ships some desktop with a recovery partition -->
	<match key="volume.label" string="PQSERVICE">
	  <merge key="volume.ignore" type="bool">true</merge>
	</match>
        <!-- HP ships desktops with a recovery partition -->
	<match key="volume.label" string="HP_RECOVERY">
	  <merge key="volume.ignore" type="bool">true</merge>
	</match>
        <!-- Sony ships laptops with a recovery partition -->
	<match key="volume.label" string="Recovery Partition">
	  <merge key="volume.ignore" type="bool">true</merge>
	</match>
        <!-- DELL ships some laptops with a visible recovery partition -->
	<match key="volume.label" string_outof="DellUtility;DellRestore">
	  <merge key="volume.ignore" type="bool">true</merge>
	</match>
        <!-- Lenovo and IBM ship with a various recovery partitions -->
	<match key="volume.label" string_outof="IBM_SERVICE;SERVICEV001;SERVICEV002">
	  <merge key="volume.ignore" type="bool">true</merge>
	</match>
      </match>

      <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>

      <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Mount</append>
      <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">ssas</append>
      <append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">mount_point fstype extra_options</append>
      <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-mount</append>

      <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Unmount</append>
      <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
      <append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
      <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-unmount</append>

      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
        <match key="volume.linux.is_device_mapper" bool="false">
          <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
          <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
          <append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
          <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>
        </match>
      </match>

      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>
      </match>

      <!-- allow these mount options for all file systems -->
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
        <append key="volume.mount.valid_options" type="strlist">ro</append>
        <append key="volume.mount.valid_options" type="strlist">sync</append>
        <append key="volume.mount.valid_options" type="strlist">dirsync</append>
        <append key="volume.mount.valid_options" type="strlist">noatime</append>
        <append key="volume.mount.valid_options" type="strlist">nodiratime</append>
        <append key="volume.mount.valid_options" type="strlist">relatime</append>
        <append key="volume.mount.valid_options" type="strlist">noexec</append>
        <append key="volume.mount.valid_options" type="strlist">quiet</append>
        <append key="volume.mount.valid_options" type="strlist">remount</append>
        <append key="volume.mount.valid_options" type="strlist">exec</append>
      </match>
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
        <append key="volume.mount.valid_options" type="strlist">ro</append>
	<append key="volume.mount.valid_options" type="strlist">noexec</append>
	<append key="volume.mount.valid_options" type="strlist">noatime</append>
      </match>

      <!-- allow these mount options for vfat -->
      <match key="volume.fstype" string="vfat">
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
	  <append key="volume.mount.valid_options" type="strlist">utf8</append>
	  <append key="volume.mount.valid_options" type="strlist">shortname=</append>
	  <append key="volume.mount.valid_options" type="strlist">codepage=</append>
	  <append key="volume.mount.valid_options" type="strlist">iocharset=</append>
	  <append key="volume.mount.valid_options" type="strlist">umask=</append>
	  <append key="volume.mount.valid_options" type="strlist">dmask=</append>
	  <append key="volume.mount.valid_options" type="strlist">fmask=</append>
	  <append key="volume.mount.valid_options" type="strlist">uid=</append>
	  <append key="volume.mount.valid_options" type="strlist">gid=</append>
	  <append key="volume.mount.valid_options" type="strlist">flush</append>
	</match>
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
	  <append key="volume.mount.valid_options" type="strlist">longnames</append>
	  <append key="volume.mount.valid_options" type="strlist">shortnames</append>
	  <append key="volume.mount.valid_options" type="strlist">nowin95</append>
	  <append key="volume.mount.valid_options" type="strlist">-u=</append>
	  <append key="volume.mount.valid_options" type="strlist">-g=</append>
	  <append key="volume.mount.valid_options" type="strlist">-m=</append>
	  <append key="volume.mount.valid_options" type="strlist">-M=</append>
	  <append key="volume.mount.valid_options" type="strlist">-L=</append>
	  <append key="volume.mount.valid_options" type="strlist">-D=</append>
	  <append key="volume.mount.valid_options" type="strlist">large</append>
	</match>
      </match>


      <!-- allow these mount options for hfs -->
      <match key="volume.fstype" string="hfs">
	<append key="volume.mount.valid_options" type="strlist">gid=</append>
	<append key="volume.mount.valid_options" type="strlist">uid=</append>
	<append key="volume.mount.valid_options" type="strlist">force</append>
      </match>

      <!-- allow these mount options for hfsplus -->
      <match key="volume.fstype" string="hfsplus">
	<append key="volume.mount.valid_options" type="strlist">force</append>
      </match>

      <!-- allow these mount options for ntfs -->
      <match key="volume.fstype" string="ntfs">
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
	  <append key="volume.mount.valid_options" type="strlist">uid=</append>
	  <append key="volume.mount.valid_options" type="strlist">gid=</append>
	  <append key="volume.mount.valid_options" type="strlist">umask=</append>
	  <append key="volume.mount.valid_options" type="strlist">utf8</append>
	</match>
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
	  <append key="volume.mount.valid_options" type="strlist">-u=</append>
	  <append key="volume.mount.valid_options" type="strlist">-g=</append>
	  <append key="volume.mount.valid_options" type="strlist">-m=</append>
	  <append key="volume.mount.valid_options" type="strlist">-a</append>
	  <append key="volume.mount.valid_options" type="strlist">-i</append>
	  <append key="volume.mount.valid_options" type="strlist">-C=</append>
	  <append key="volume.mount.valid_options" type="strlist">-W=</append>
	</match>
      </match>

      <!-- allow these mount options for ext3 -->
      <match key="volume.fstype" string="ext3">
	<append key="volume.mount.valid_options" type="strlist">acl</append>
	<append key="volume.mount.valid_options" type="strlist">user_xattr</append>
	<append key="volume.mount.valid_options" type="strlist">data=</append>
      </match>

      <!-- allow these mount options for ext2 -->
      <match key="volume.fstype" string="ext2">
	<append key="volume.mount.valid_options" type="strlist">acl</append>
	<append key="volume.mount.valid_options" type="strlist">user_xattr</append>
      </match>

      <!-- allow these mount options for reiserfs -->
      <match key="volume.fstype" string="reiserfs">
	<append key="volume.mount.valid_options" type="strlist">acl</append>
	<append key="volume.mount.valid_options" type="strlist">user_xattr</append>
      </match>

      <!-- allow these mount options for ufs -->
      <match key="volume.fstype" string="ufs">
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
	  <append key="volume.mount.valid_options" type="strlist">ufstype=</append>
	</match>
      </match>

      <!-- udf -->
      <match key="volume.fstype" string="udf">
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
	  <append key="volume.mount.valid_options" type="strlist">uid=</append>
	  <append key="volume.mount.valid_options" type="strlist">umask=</append>
	</match>
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
	  <append key="volume.mount.valid_options" type="strlist">-C=</append>
	  <append key="volume.mount.valid_options" type="strlist">-v</append>
	</match>
      </match>

      <!-- iso9660 -->
      <match key="volume.fstype" string="iso9660">
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
	  <append key="volume.mount.valid_options" type="strlist">utf8</append>
	  <append key="volume.mount.valid_options" type="strlist">uid=</append>
	  <append key="volume.mount.valid_options" type="strlist">mode=</append>
	  <append key="volume.mount.valid_options" type="strlist">iocharset=</append>
	</match>
	<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="FreeBSD">
	  <append key="volume.mount.valid_options" type="strlist">extatt</append>
	  <append key="volume.mount.valid_options" type="strlist">gens</append>
	  <append key="volume.mount.valid_options" type="strlist">nojoliet</append>
	  <append key="volume.mount.valid_options" type="strlist">norrip</append>
	  <append key="volume.mount.valid_options" type="strlist">nostrictjoliet</append>
	  <append key="volume.mount.valid_options" type="strlist">-s=</append>
	  <append key="volume.mount.valid_options" type="strlist">-C=</append>
	  <append key="volume.mount.valid_options" type="strlist">-v</append>
	</match>
      </match>

      <!-- allow these unmount options -->
      <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" string="Linux">
        <append key="volume.unmount.valid_options" type="strlist">lazy</append>
      </match>

    </match>

    <!-- make sure we export Eject on discs where we don't recognize the file system -->
    <match key="volume.is_disc" bool="true">
      <match key="volume.fsusage" string="">
        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>
      </match>
    </match>

    <match key="storage.requires_eject" bool="true">
        <!-- storage Eject causes eject on each volume on this storage -->
        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Storage</append>
        <append key="org.freedesktop.Hal.Device.Storage.method_names" type="strlist">Eject</append>
        <append key="org.freedesktop.Hal.Device.Storage.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Storage.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Storage.method_execpaths" type="strlist">hal-storage-eject</append>

        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Storage</append>
        <append key="org.freedesktop.Hal.Device.Storage.method_names" type="strlist">CloseTray</append>
        <append key="org.freedesktop.Hal.Device.Storage.method_signatures" type="strlist">as</append>
	<append key="org.freedesktop.Hal.Device.Storage.method_argnames" type="strlist">extra_options</append>
        <append key="org.freedesktop.Hal.Device.Storage.method_execpaths" type="strlist">hal-storage-closetray</append>
    </match>
  </device>
</deviceinfo>
cat /etc/hal/fdi/policy/preferences.fdi:
Code:
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->

<!-- 
  Some examples how to use hal fdi files for system preferences 
  You can either uncomment the examples here or put them in a seperate .fdi
  file.
-->
<deviceinfo version="0.2">
<!-- 
  The following shows how to hint gnome-volume-manager and other programs 
  that honor the storage.automount_enabled_hint to not mount non-removable
  media.
-->
<!--
  <device>
    <match key="storage.hotpluggable" bool="false">
      <match key="storage.removable" bool="false">
        <merge key="storage.automount_enabled_hint" type="bool">false</merge>
      </match>
    </match>
  </device>
-->
</deviceinfo>
Cheers,
Mike.
 
Old 11-19-2009, 02:59 PM   #2
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
I've never tried doing that - I usually just have /dev/sdb1 mount with the users and umask settings.
I'll look into the HAL options
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Automount LUKS encrypted USB disk as regular user gargamel Slackware 11 10-31-2009 05:13 AM
How to auto mount usb drives as a normal user basheer Slackware 3 10-24-2009 10:26 PM
Soon to be first time Linux user - Question about USB Flash Drives CT_0000 Linux - Newbie 4 09-30-2009 04:19 PM
USB/ntfs drive and user permissions FC3noob Linux - Newbie 1 02-16-2005 10:37 AM
Give user permission to mount/use cdrom drives or usb drives zwyrbla Linux - Newbie 2 08-23-2004 04:30 PM


All times are GMT -5. The time now is 12:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration