Search:  
Gentoo Wiki

Ivman

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Goal

The goal of this article is to setup ivman to automount devices.

Please note: some of this information may be very out of date for older versions of ivman, especially ivman 0.5.x. Please use the most up-to-date Ivman marked stable in portage.

Required Software

Warning: ivman-0.6.12 does not work with dbus-1.0.2, both stable in portage. However ivman-0.6.13 does, it is currently the most recent stable release in portage.

All required packages are in the portage, so it's easy to obtain the software:

Code: Installing ivman
emerge -av ivman

Unmask required packages if necessary.

If the HAL merge complains about "u64" or "BLKGETSIZE64" not being defined and you are using a 2.6 kernel, update your linux-headers:

Code: Update linux-headers
emerge --oneshot linux-headers

As soon as the headers are successfully upgraded, remerge glibc:

Code: Re-emerge glibc
emerge --oneshot glibc

Setting up

There are two ways to use Ivman: as root, or as a regular user. There are advantages and disadvantages to each method.

Starting ivman as root

Starting ivman as a regular user

Code: Add ivman-user to start scripts

rc-update add ivman-user default

Note: If this command complains about /etc/init.d/ivman-user not being executable, run chmod +x /etc/init.d/ivman-user and try again.


Warning: Remember to replace username with your system username in the start section, in the script below.
File: /etc/init.d/ivman-user
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/sys-apps/ivman/files/ivman-0.3.init,v 1.1 2004/10/19 17:15:33 eradicator Exp $

depend() {
        need hald
}

start() {
        ebegin "Starting Automounter (user)"
        start-stop-daemon --background --start --chuid username --pidfile /var/run/ivman-user.pid --make-pidfile --exec /usr/bin/ivman > /dev/null
        eend $?
}

stop() {
        ebegin "Stopping Automounter (user)"
        start-stop-daemon --stop --pidfile /var/run/ivman-user.pid
        eend $?
}

Ivman should not require any additional configuration for automounting. fstab entries are not required, and removable drives/disks will be mounted under /media. However, Ivman can be used to do much more than automounting. Feel free to add your extra rules to this page :-)

A Few Example Rules

Note: a couple of these just need to be uncommented in the file, but I figure it is nice to show the capabilities

Mount everything we can:

File: /etc/ivman/IvmConfigActions.xml
    <ivm:Match name="ivm.mountable" value="true">
        <ivm:Option name="mount" value="true" />
    </ivm:Match>
 


A nice mounting script can be found in the article about UDEV. Here's how you can activate it:

File: /etc/ivman/IvmConfigBase.xml
    <!-- mount command.  default is autodetected.  Must be specified with
         umountcommand. -->
    <ivm:Option name="mountcommand" value="mount-device.sh '$hal.block.device$'" />

    <!-- umount command.  default is autodetected.  Must be specified with
         mountcommand. -->
    <ivm:Option name="umountcommand" value="umount '$hal.block.device$'" />
 


Open my mp3 player with mc when its plugged in:

File: /etc/ivman/IvmConfigActions.xml
    <ivm:Match name="hal.info.product" value="IAUDIO">
    	<ivm:Option name="exec" value="xterm -e mc /home/share/music /media/IAUDIO" />
    </ivm:Match>
 

Open my camera with mc when it's plugged in:

File: /etc/ivman/IvmConfigActions.xml
    <ivm:Match name="hal.info.vendor" value="FUJIFILM">
    	<ivm:Option name="exec" value="xterm -e mc /home/share/pics /media/usbdisk/DCIM/100_FUJI" />
    </ivm:Match>
 

This is helpful. I use it and I don't even have KDE. It pops up a little thing saying what device is plugged in.

File: /etc/ivman/IvmConfigActions.xml
    <ivm:Match name="hal.info.category" value="storage">
      <ivm:Match name="hal.storage.bus" value="usb">
         <ivm:Option name="exec" value="kdialog --passivepopup 'USB storage device detected: $hal.info.vendor$ $hal.info.product$' 4" />
      </ivm:Match>
   </ivm:Match>
 

How to Make your own rules

There is probably a better way to do this, but this is what I did:

  1. Include the last example I put up there so that you computer tells you the name of the device
  2. then run the command lshal > halstuff
  3. use a text editor such as "vi" to find where the entry is
  4. find an original data item for the device (Notice that my examples above use different items. They aren't always consistent.)
  5. use the syntax in my examples above to come up with your own commands

Troubleshooting

Miscellaneous

HAL may require coldplug added to the boot runlevel in order to properly detect USB devices.

If you're having trouble getting the per-user ivman to automount your USB flash drive, you might need to add utf-8 support to your kernel. See this forum thread for details.

Using fstab entries (ivman 0.6.x or greater)

Ivman 0.6.x or greater uses pmount to mount your drives, and thus does NOT need any fstab entries. However, fstab entries may still be used if necessary, though you are suggested to avoid them when possible.

Special care must be followed with USB hard disk. For them to work well, init must be able to check them at boot time when needed. So, I recommand a fstab entry in this case.

pmount (and thus Ivman) will automatically respect your fstab entries. From version 0.6.0, even symbolic links are treated properly, without the use of IvmConfigMappings.xml. This means that any device present in your fstab, will not be created and mounted in /media.

Using fstab entries (ivman 0.5.x ONLY!)

Ivman 0.5.x still respects your /etc/fstab. If you were previously using supermount, the entries you had to use then won't work with ivman. Change them back. For example:

File: /etc/fstab
/dev/cdroms/cdrom0      /mnt/cdrom      iso9660         noauto,ro               0 0

It may also be necessary to disable devfs.

Mounting devices to be unmountable by normal users (ivman 0.5.x ONLY!)

When you plug in your USB key, a root instance of ivman mounts it automatically, but you can't unmount it unless you are root. This is a work around to solve it, although it tells HAL to mount all mass storage devices with the "users" option, which may be something you don't want.

Create a file called whatever.fdi in /usr/share/hal/fdi/95userpolicy/ with the following contents:

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

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

</deviceinfo>

For more info, look at the HAL Specifications.

Other Problems

ivman still doesn't work

If ivman still doesn't work, first stop it:

Code: Stopping ivman
/etc/init.d/ivman stop

and then edit the base config:

Code: Editing the base config
nano -w /etc/ivman/IvmConfigBase.xml

Disable fork, and set debugging to true. Then, start ivman from console

Code: Starting ivman
ivman

Save the messages. If you need help understanding them, you're welcome to come to #love-sources or #ivman @ freenode irc://freenode.net/#love-sources or irc://freenode.net/#ivman .

USB disks don't mount (fixed in 0.6.14)

Ivman mounts by default only removable media. USB disks are not removable, only hotpluggable. Until ivman is fixed you can create a policy that all hotpluggable storage should be mounted. This can be done by copying the following as /etc/hal/fdi/policy/mountpolicies.fdi:

File: /etc/hal/fdi/policy/mountpolicies.fdi
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!-- -*- SGML -*- -->
    <deviceinfo version="0.2">
      <device>
        <match key="info.category" string="storage">
          <match key="storage.hotpluggable" bool="true">
            <merge key="storage.policy.should_mount" type="bool">true</merge>
          </match>
        </match>
      </device>
    </deviceinfo>

Restart hald: /etc/init.d/hald restart

More info at Triggering software events from hardware changes with HAL and Ivman

See also

Retrieved from "http://www.gentoo-wiki.info/Ivman"

Last modified: Wed, 27 Aug 2008 04:37:00 +0000 Hits: 86,656