# HAL/ivman Problems: Removable Storage and Safe Removal

## davecs

I have two problems getting HAL/DBUS/ivman working as it should.

I have a USB Key which is correctly recognised and appears on my desktop when I insert it. However, when I right-click on it, and select "Safely Remove" from its menu, I get a umount error that only root can unmount. Clearly I need to know what to do when there is "write-behind" data preventing me from just pulling... How do I get "normal" access to this function? The same happens for my optical drive, though it is possible to eject the disk using the button on the drive. The icon then disappears. I cannot eject it using the "eject" command on the right-click menu.

Secondly, I have other removable storage devices, Two of them are card readers. When I plug them in with a card, they do not mount automatically, and "media:/" in konqueror shows then as Hard Disc devices rather than removable storage.

Third thing is, I have given the removable storage items device filesystem names using udev.

How can I

1 - enable user-level  permissions for unmount?

2 - force certain removable storage media to be recognised as such?

3 - can I force the mount directory name according to the /dev filesystem name?

I have read the manuals but cannot make much sense of them ...

----------

## thesnowman

I don't know about question 1, but for 2 and 3 have a look at this article:

http://www.kgarner.com/blog/archives/2005/01/11/fc3-hal-ipod/

That article explains how to write a HAL fdi (device information file).

----------

## atdsm

*bump

(I'm interested in the answer too.)

----------

## atdsm

I found a work around, although not an ideal one...

For users to be able to unmount a drive, the "users" option must be appended to the line in fstab... e.g.

```

/dev/hdd                /media/cdrom            auto    users,exec,noauto,managed 0 0

```

However, hal modifies fstab on the fly with fstab-sync, thus creating custom entries. Therefore, you can't just go add "users" to the fstab entry, because hal will modify/overwrite/delete that entry the next time you start it up (or stop it for that matter). So the question becomes, how do I get hal to append the "users" option to all the other stuff it writes in fstab?

The answer is that hal uses a bunch of big, complicated xml files to define what "policies" it uses. The HAL 0.5.1 Specification explains all this pretty thouroughly. It loads these xml rulesets from /usr/share/hal/fdi/ . HAL loads all rulesets, starting with the lowest numbers and working up. Higher numbers override what was specified lower down, so you can change the default rules it loads by adding a rules file (let's call it custom.fdi) in /usr/share/hal/fdi/95userpolicy/ .

In this file you can add a line that makes HAL append "user" to the entries it puts in fstab. Without going into too much detail (you can find that in the spec I provided above), the file needs to look like this:

```

deepthought steve # cat /usr/share/hal/fdi/95userpolicy/custom.fdi 

<?xml version="1.0" encoding="ISO-8859-1"?> <!-- -*- SGML -*- --> 

<deviceinfo version="0.2">

  

  <!-- Append users to default mount options -->

  <device>

    <merge key="storage.policy.default.mount_option.users" type="bool">true</merge>

  </device>

</deviceinfo>

```

Unfortunately, if you don't want to specify "users" for everything hal does, you are out of luck. There is no way to specify just to use that for usb drives. (As a side note, at first glance using the storage.policy.mount_option.* key in the specification looks promising, but on second glance that key is only relevant if the device you are mounting is partitionless... which USB drives aren't. So you can set it up to append "users" to only USB drives, but then hal goes off and ignores you because usb drives have partitions...)

Anyway, having "users" on all my drives is an acceptable workaround for me for now. Hope this helps.

Steve

----------

## davecs

Thanks.

What I actually did is installed pmount instead. Much better. Now when you plug in a device, an item pops up that anyone can mount. And unmount.

----------

## afabco

an item pops up *where*?  

I'm an old console/command line fuddy-duddy....is this pmount thing only for the graphically inclined?

----------

## MadEgg

Nope, pmount is a wrapper around the original mount command which can mount as any user. You can just emerge it and than enter 'pmount' in the console for some command line options. You will need the UDI of the inserted device to mount it though.

----------

