• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

USB flash drive woes

Eponasoft

Active Member

Thanks: 10
Messages: 218

#1
This has been bugging me for awhile now so I figured I would try to fix it since I'm installing FreeBSD on another system right now, and the user is gonna need it.

The issue is automounting flash drives in a normal account. My user account is in both wheel and operator. I'm using FreeBSD 7.2 and KDE 3.5. When I insert the flash drive, KDE pops up a dialog asking what to do with the inserted volume, but then I get an error message from mount_msdosfs saying that the operation is not permitted. In order to fix it, I've read that the mount point should be chown'd to the user account. Well, the system won't let me do that.

Anyways, if anyone can help out in this case, just tell me what I need to post that will shed some light on this issue...conf files, directory settings, etc...I just want to get it working. Thanks. :D
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator

Thanks: 2,451
Messages: 11,084

#3
Isn't this the [cmd=]sysctl vfs.usermount=1[/cmd] stuff? My Kingston sticks automount under /media, which is root:wheel-owned. (/media/KINGSTON is created there, to be precise, and that one has my user:user permissions). I can use them fine as 'normal user', including mounting and unmounting, reading and writing.
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#4
Pretty much all of this was already done on my system, though I hadn't gotten this far with the system I'm working on right now. The thing is that I want things to automount; I don't want to have to mount it manually, as the user of this system is not going to be able to do that (she's not exactly computer-savvy). If I start up X with KDE3.5 as the superuser, everything works as I want it to work. Now...I have created subdirectories inside of /mnt and chown'd them correctly. I'm currently waiting for OOo to finish building (holy hell this takes forever!), but after rebooting, how can I get the system to automount to /mnt/username? The above links didn't shed any light on that, unfortunately...I've read a little about sysutils/automount...is this an option, and if so, how? Thanks. :D
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#6
After OOo finally finished building, I rebooted and checked to see if the flash drive would automount...not only did it not automount but I didn´t even get the dialog. Also, the CDROM almost worked, it could not mount but at least it was detected. What kind of changes did you make to policykit.conf to get everything to work? I have the CDROM working on my own system, but I do not remember how I got it working. :)
 

kpedersen

Aspiring Daemon

Thanks: 218
Messages: 991

#7
Hmm what I usually do for Xfce / gnome / kde is...

in rc.conf
Code:
hald_enable="YES"
dbus_enable="YES"
in Policykit.conf
Code:
<match user="root"> <----- remove
  <return result="yes"/>
</match> <------ remove
in /etc/fstab
Code:
proc           /proc       procfs  rw  0   0
Yes... HAL uses procfs :(

Then after a reboot. Everything seems to automount no problem

Basically, it doesnt seem that the user needs to mount anything... It is all handled by HAL. therefor, the usermount stuff is not important.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,471
Messages: 25,628

#8
kpedersen said:
in Policykit.conf
Code:
<match user="root"> <----- remove
  <return result="yes"/>
</match> <------ remove
This will basically allow all users everything. If that's not what you want this might be a better solution:

Code:
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->

<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">

<!-- See the manual page PolicyKit.conf(5) for file format -->

<config version="0.1">
    <match user="root">
        <return result="yes"/>
    </match>
    <define_admin_auth group="wheel"/>
    <match action="org.freedesktop.hal.storage.mount-removable">
        <match user="dice">
                <return result="yes"/>
        </match>
    </match>
    <match action="org.freedesktop.hal.storage.mount-fixed">
        <match user="dice">
                <return result="yes"/>
        </match>
    </match>
    <match action="org.freedesktop.hal.storage.eject">
        <match user="dice">
                <return result="yes"/>
        </match>
    </match>
</config>
Change the "match user" accordingly.
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator

Thanks: 2,451
Messages: 11,084

#9
Mine is:

Code:
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->

<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">

<!-- See the manual page PolicyKit.conf(5) for file format -->

<config version="0.1">
    <match user="dutchd|root">
	<return result="yes"/>
    </match>

    <define_admin_auth group="wheel|operator"/>

<match action="org.freedesktop.hal.power-management.shutdown">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.power-management.reboot">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.power-management.suspend">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.power-management.hibernate">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.eject">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.mount-fixed">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.mount-removable">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.unmount-others">
    <return result="yes"/>
</match>

</config>
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#10
OK thanks a lot everyone...I´ll give this a go and see if it works. :D
 

kpedersen

Aspiring Daemon

Thanks: 218
Messages: 991

#11
Since we are talking about HAL,
Does anyone know the future of it within FreeBSD?
Isn't it meant to become depricated?
How did automount use to work before we got HAL?
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#12
OK this all worked for the USB drive. I can now insert it, find it in ¨Storage Media¨, write files to it, and safely remove it. That helped a ton. :) KDE doesn´t pop up a dialog for it though, but that is not really a huge issue. However, I am still having problems with the CDROM...it is detected, and shows up in ¨Storage Media¨, but I cannot mount it as a normal user...
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator

Thanks: 2,451
Messages: 11,084

#13
See if you can glean something from the docs in /usr/local/share/PolicyKit/policy/.

For the record: when I insert a CD into my internal CD/DVD reader/writer on my laptop, I do get a pop-up in XFCE:

Code:
Failed to mount "User Manual".
mount_cd9660: /dev/acd0: Operation not supported by device.
The icon does show up on the desktop though.

Syslog is stumm about it.
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#14
OK...I´m assuming that this is the correct file...

/usr/local/share/PolicyKit/policy/org.freedesktop.hal.storage.policy

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">

<!-- 
Policy definitions for HAL's drives/media mechanims.

Copyright (c) 2007 David Zeuthen <david@fubar.dk>

HAL is licensed to you under your choice of the the Academic Free
License Version 2.1, or the GNU General Public License version 2. Some
individual source files may be under the GPL only. See COPYING for
details.
-->

<policyconfig>

  <action id="org.freedesktop.hal.storage.mount-fixed">
    <description>Mount file systems from internal drives.</description>
    <message>System policy prevents mounting internal media</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep_always</allow_active>
    </defaults>
  </action>
  
  <action id="org.freedesktop.hal.storage.mount-removable">
    <description>Mount file systems from removable drives.</description>
    <message>System policy prevents mounting removable media</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  
  <action id="org.freedesktop.hal.storage.unmount-others">
    <description>Unmount file systems mounted by other users.</description>
    <message>System policy prevents unmounting media mounted by other users</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep_always</allow_active>
    </defaults>
  </action>
  
  <action id="org.freedesktop.hal.storage.eject">
    <description>Eject removable media.</description>
    <message>System policy prevents ejecting removable media</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>
  
  <action id="org.freedesktop.hal.storage.crypto-setup-fixed">
    <description>Set up decryption for encrypted fixed storage devices.</description>
    <message>System policy prevents accessing encrypted fixed media</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep_always</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.hal.storage.crypto-setup-removable">
    <description>Set up decryption for encrypted removable storage devices.</description>
    <message>System policy prevents accessing encrypted removable media</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

</policyconfig>
 

mfaridi

Aspiring Daemon

Thanks: 14
Messages: 663

#15
DutchDaemon said:
Mine is:

Code:
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->

<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">

<!-- See the manual page PolicyKit.conf(5) for file format -->

<config version="0.1">
    <match user="dutchd|root">
	<return result="yes"/>
    </match>

    <define_admin_auth group="wheel|operator"/>

<match action="org.freedesktop.hal.power-management.shutdown">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.power-management.reboot">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.power-management.suspend">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.power-management.hibernate">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.eject">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.mount-fixed">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.mount-removable">
    <return result="yes"/>
</match>

<match action="org.freedesktop.hal.storage.unmount-others">
    <return result="yes"/>
</match>

</config>
what I must do when I have three user for example bob,john,robert and I want all of them can mount USB and umount it
 

kpedersen

Aspiring Daemon

Thanks: 218
Messages: 991

#18
to get the cdrom auto mounting...

make sure the cdrom entry has been removed from /etc/fstab

and then HAL should be able to mount it when a new cd is inserted

I assume this is because if it is mounting something and it is found in HAL, it tried to mount it as the current user.. Which will generally fail.

http://www.freebsd.org/gnome/docs/halfaq.html
NOTE: Volumes that you wish to manage using hal should NOT be listed in /etc/fstab. This is especially true for CD devices and floppy disk devices.
The HAL faq on this site is really useful for Xfce even though it is orientated to gnome.
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator

Thanks: 2,451
Messages: 11,084

#19
make sure the cdrom entry has been removed from /etc/fstab
Well spotted. I always forget about the interplay between HAL and fstab!

Code:
Jan 21 18:09:00 box hald: mounted /dev/acd0 on behalf of uid 1001
Jan 21 18:09:09 box hald: unmounted /dev/acd0 from '/media/User Manual' on behalf of uid 1001
All desktop functions (notification, ejecting, icon) working just dandy. Thanks for the reminder.
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#20
OK, /etc/fstab had it set like that when fbsd was installed. I´ve removed it, and will test it out after rebooting (building GIMP at the moment, another fun time indeed). Thanks for the hint...I bet it´ll work now. :)
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#22
Yep, that seems to be the case, as when I popped in a CD, it automatically mounted it as the normal user and I could view its contents. No reboot required.
 

Beno Kurniawan

New Member


Messages: 9

#24
Dear Sir,
I have looking how to mount usb as user on KDE, and by reading this thread I finally succeed. I wonder if you could share how to mount ntfs format external hardisk? It cannot be mounted even though I have install fusefs-ntfs and enable fuse. Tried to do what written on handbook about vfs.usermount=1 and autofs, this takes me unable to mount usb which previously works. So I undo all the steps back to the state where I can mount the usb sticks.
Thanks in advance for your kind help.
Regards,
Beno