HAL and ROX (auto-detecting USB sticks, etc)
HAL and ROX
With HAL and Ivman and pmount,
you can have devices like CD-ROMs and USB flash sticks be automatically mounted and added to your panel. When you unmount it the mountpoint will be removed from your panel.
Setup
The following was tried with Udev 070, HAL 0.5.4, DBus 0.50, Ivman 0.6.4, and pmount 0.9.3.
We are going to set things up so that Ivman is run as root and handles the automounting under /media , with the help of pmount.
Then users can run their own instances of Ivman too, to handle desktop specific stuff (like adding devices to the panel).
- Make sure there is nothing in /etc/hal/device.d that does any mounting, becouse we want ivman to handle the mounting!
- Patch pmount to check for group. http://kymatica.com/stuff/pmount-0.9.3-lijon.patch This way users can unmount the devices even though it was mounted by the root ivman.
- Make sure there is a haldaemon system group and user, and a plugdev group. Add all users that should be able to access and unmount removable media to the plugdev group. Note that users must log out and in again for the group changes to take effect
- Make sure the DBus system bus is started:
dbus-daemon --system
- Make sure that /media (or whatever is configured) is existing, or else create it.
- Start HAL as root:
hald --daemon=yes --retain-privileges
- Start Ivman as root:
ivman
NOTE: If all this works, don't forget to check that dbus, hald and ivman is started as above in your bootscripts...
- Make sure Ivman is started as your user too: Add this script in your Auto Start folder:
#!/bin/sh exec 1>&2 echo -n "Launching volume manager... " if ps -C ivman -o user | grep -q $USER then echo "Already running." exit else echo "OK" exec ivman fi
- Disable mounting with usermode ivman, or else there will be problems if more than one user is logged in and running ivman at the same time... We want the root ivman to handle mounting. In ~/.ivman/IvmConfigActions.xml, comment out this section:
<!-- <ivm:Match name="ivm.mountable" value="true"> <ivm:Option name="mount" value="true" /> </ivm:Match> -->
Ivman rules to add devices to your panel
- For this to work, HAL needs this small patch applied:
--- hal-0.5.4/hald/linux2/blockdev.c 2005-08-10 06:05:58.000000000 -0300 +++ hal-0.5.4-lijon/hald/linux2/blockdev.c 2005-10-21 19:15:28.000000000 -0200 @@ -202,7 +202,7 @@ device_property_atomic_update_begin (); hal_device_property_set_bool (d, "volume.is_mounted", FALSE); - hal_device_property_set_string (d, "volume.mount_point", ""); +// hal_device_property_set_string (d, "volume.mount_point", ""); device_property_atomic_update_end (); HAL_INFO (("Clearing mount point for %s", device_file));
- Create a script named ~/bin/rox.panelput and make it executable:
#!/bin/sh ### Change "Top" below to the panel you want your devices on... rox --RPC << EOF <?xml version="1.0"?> <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> <env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer"> <Panel$1> <Side>Top</Side> <Path>$2</Path> </Panel$1> </env:Body> </env:Envelope> EOF
- And here comes the ivman rule, which should be inserted in your ~/.ivman/IvmConfigProperties.xml
<ivm:Match name="ivm.mountable" value="true"> <ivm:Property name="hal.volume.is_mounted"> <ivm:Action value="true" exec='rox.panelput Add "$hal.volume.mount_point$"' /> <ivm:Action value="false" exec='rox.panelput Remove "$hal.volume.mount_point$"' /> </ivm:Property> </ivm:Match>
A nice ~/bin/eject script:
This lets you unmount your media and also FUSE mountpoints with the Eject entry on the ROX-Filer file menu.
Don't forget to make the script executable.
#!/bin/sh pumount "$1" 2>/dev/null || fusermount -u "$1" 2>/dev/null || echo "Could not unmount with pumount or fusermount -u" >&2
More patches
Spaces in mountpoint names
Ivman 0.9.3 has the problem that mountpoints are not enclosed by quotes when passed as arg to pmount. So if a inserted media has spaces in the desired mount point, pmount will fail! look in ivmans src/manager.c:619 and put \" around the $hal.volume.desired_mount_point$ thing...
Better mountpoint names
At least for me, my CD-ROM's got mounted as /media/hde and stuff like that, this patch to /usr/share/hal/fdi/policy/10osvendor/10-storage-policy.fdi fixed it so that media is mounted with the volume label as mountpoint:
--- /System/Links/Shared/hal/fdi/policy/10osvendor/10-storage-policy.fdi 2005-10-21 19:18:07.000000000 -0200 +++ /System/Settings/hal/fdi/policy/10-storage-policy.fdi 2005-10-22 13:12:44.000000000 -0200 @@ -96,8 +96,7 @@ <match key="block.is_volume" bool="true"> <match key="volume.fsusage" string="filesystem"> <!-- skip for drives with the no partitions hint (they are handled above) --> - <match key="@block.storage_device:storage.no_partitions_hint" bool="false"> - +<!-- <match key="@block.storage_device:storage.no_partitions_hint" bool="false"> --> <merge key="volume.policy.should_mount" type="bool">true</merge> <merge key="volume.policy.mount_filesystem" type="copy_property">volume.fstype</merge> @@ -173,7 +172,7 @@ <merge key="volume.policy.should_mount" type="bool">true</merge> </match> </match> - </match> +<!-- </match> --> </match> </match>
Good luck!
- Printer-friendly version
- Login to post comments
Recent comments
2 years 8 weeks ago
2 years 17 weeks ago
3 years 1 week ago
3 years 5 weeks ago
3 years 9 weeks ago
3 years 10 weeks ago
3 years 10 weeks ago
3 years 14 weeks ago
3 years 14 weeks ago
3 years 15 weeks ago