Skip to main content

Alternative SUSE's hal policy

After about two miserable weeks searching for solution about `umounting USB sticks problem', I can finally figure out how to make things work. Somebody told me after my post in SuSEForums.net that someone reported this bug to Novell's bugzilla. Don't know if he/she had this problem before me or not. One thing that bothered me, is that just a few people scream for this annoyingdisturbance. And now is been a couple months after the release of OpenSUSE 10.0.

Some people say that this could not be a problem, since we can simply unplug the usb devices (USB sticks) and it won't ruin the filesystem in the device. ButI don't think it's a convenient nor the right way. A lot of people, I think mostly, only feel comfortable to unplug their USB sticks after the computer told them that it can be safely removed. They probably don't know what is happening in the system. But in some cases, system notification about this is truly necessary, because most people never know if there are processes that accessed files in their storage media. These open files are certainly inhibit the umounting process, and --maybe-- can corrupt the filesystem if we carelessly unplug the still mounted device.According to a workaround by Danny Kukawka about static mount point for removable media and the corrected hal policy for unsynced writing to USB media (10.0 Release Notes), I arrange this alternative hal policy, saved in the file /usr/share/hal/fdi/policy/20thirdparty/90-storage-nosync.fdi.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id: 90-storage-nosync.fdi,v 1.0 06/12/2005 idud Exp $ -->
<deviceinfo version="0.2">
<device>
<match key="resmgr.class" string="floppy">
<merge key="volume.policy.mount_option.sync"
type="bool">false</merge>
<merge key="storage.policy.mount_option.users"
type="bool">true</merge>
<match key="block.device" string="/dev/sda1">
<merge key="volume.policy.desired_mount_point"
type="string">USBa0</merge>
</match>
<match key="block.device" string="/dev/sdb1">
<merge key="volume.policy.desired_mount_point"
type="string">USBb0</merge>
</match>
<match key="block.device" string="/dev/sdc1">
<merge key="volume.policy.desired_mount_point"
type="string">USBc0</merge>
</match>
<match key="block.device" string="/dev/sdd1">
<merge key="volume.policy.desired_mount_point"
type="string">USBd0</merge>
</match>
<match key="block.device" string="/dev/sde1">
<merge key="volume.policy.desired_mount_point"
type="string">USBe0</merge>
</match>
<match key="block.device" string="/dev/sdf1">
<merge key="volume.policy.desired_mount_point"
type="string">USBf0</merge>
</match>
</match>
</device>
</deviceinfo>

And adding these lines to the /etc/fstab:
/dev/sda1 /media/USBa0 auto noauto,users,exec 0 0
/dev/sdb1 /media/USBb0 auto noauto,users,exec 0 0
/dev/sdc1 /media/USBc0 auto noauto,users,exec 0 0
/dev/sdd1 /media/USBd0 auto noauto,users,exec 0 0
/dev/sde1 /media/USBe0 auto noauto,users,exec 0 0
/dev/sdf1 /media/USBf0 auto noauto,users,exec 0 0

I didn't create /media/USB{a,b,c,d,e,f}0 directories, because hal will create them before mounting the plugged device and remove them once the device unplugged. After restarting the hal service, then plugging in my USB stick, I get the flash icon appear on my desktop, a dialog window asking me if I to open a file manager or not, and this `mount' output:
idud@nyemot[~]$ mount | grep -i usb
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /media/USBa0 type subfs
(rw,nosuid,nodev,fs=floppyfss,procuid,iocharset=iso8859-1)

After konquering the files --clicking here and there-- I right-click the desktop's flash icon, selecting `safely remove', and the icon disappear. The mount output became:
idud@nyemot[~]$ mount | grep -i usb
usbfs on /proc/bus/usb type usbfs (rw)

It works! Umounting process ended successfully. Believe it or not, this rough solution makes me feel better. I can unplug the stick without any hesitation. But, this can only work for me, so I'm not recommend you to use this.``So, what's your intention in writing this?''

I, too, don't know. Just a hobby, I guess.

--- Edited for better view :D

Comments

Anonymous said…
You can also use sudoers:

http://forums.suselinuxsupport.de/index.php?s=&showtopic=26973&view=findpost&p=130824

Cheers
Anonymous said…
Great, it works excellent, thank you very much for your time!
--
Jeremy
Anonymous said…
unfortunately this didn't work for me. My usb drive is always mounted as /media/usbdisk and usually as /dev/sda or /dev/sdb. I wonder if this is because I have upgraded - I went suse 9.1-9.2-9.3-10.0

Evidently this is because of:
/usr/share/hal/fdi/policy/10osvendor/10-storage-policy.fdi

It has a line about apending with "disk" so I think that's where it must be coming from - and frankly I'm not competent enough to start digging around in that.
idud said…
I think it's because you use USB 1.1. It's easy, I guess, just to register

/dev/sda /media/usbdisk auto users 0 0
...

in the /etc/fstab.

Or maybe you can add a partition to your usb drive, eg. using cfdisk, and then format it with mkdosfs (for use with vfat).
Anonymous said…
on https://bugzilla.novell.com/show_bug.cgi?id=117945
on the comment dated 2006 01 21, Roberto Grassi mentioned that you can edit the /opt/kde3/share/apps/konqueror/servicemenus/media_safelyremove.desktop
instead of
Exec=kio_media_mounthelper -s %u
change the -s to -e:
Exec=kio_media_mounthelper -e %u

This has worked for me. I don't know what the difference is between this fix and the one on this page.

I too have been affected by this problem, and by the slow usb problem. I really like Suse, but this just puts me right off it. I've since been able to fix this, now that more info is about. Thing is, people say you can just unplug without umounting it. But the slow usb fix requires that you turn off synchronous writing, which in turn means that you need to unmount it before removing it! So I don't see how this could be a trivial issue (I'd like to keep my usb key usable thanks!)