Ivman

From Gentoo Linux Wiki

Jump to: navigation, search

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

Fix me: 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.

Contents

[edit] Kernel configuration

Ivman uses pmount. If you have an older pmount version than 0.9.19, pmount uses sysfsutils, which is broken and relies on the deprecated CONFIG_SYSFS_DEPRECATED_V2 option in your kernel. So you have to either update pmount to version 0.9.19 or later or enable the deprecated kernel option, recompile, install and reboot your kernel.

[edit] Installation

As easy as:

# emerge -av ivman

You will likely want to start ivman at startup, so:

# rc-update add ivman default

If you want to start it directly:

# /etc/init.d/ivman start

[edit] Configuration

A basic volume management configuration is already in place in /etc/ivman/. You may want to tweak this a little bit.

[edit] ivman user

By default, ivman runs as the ivman user. If you want to unmount volumes as nonroot, you will need to tell ivman to run as that user instead. Edit /etc/ivman/IvmConfigBase.xml (yeah, ivman uses XML files. it's bad, but we'll have to live with it):

File: /etc/ivman/IvmConfigBase.xml

find this line:

<ivm:Option name="user" value="ivman" />

And change it into:

<ivm:Option name="user" value="jack" />

Where jack is the user who will unmount volumes. Add jack to the plugdev group:

# gpasswd -a jack plugdev

Now, if jack wishes to unmount /dev/sda1, which ivman mounted at /media/sda1/, he would:

$ pumount /media/sda1

[edit] A Few Example Rules

Note: A couple of these just need to be uncommented in the configuration files, so search carefully before adding them to save yourself precious time.

[edit] Different mount command

If you have to add some special options to the mount command, you can modify these configuration lines:

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$'" />

You could, for example, configure the mountcommand to mount using -o users, which will allow all users to mount and unmount the volume.

[edit] Execute programs

Open an 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 your 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 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>

[edit] Tips 'n tricks

[edit] 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:

File: /usr/share/hal/fdi/95userpolicy/
<?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, read the HAL Specifications.

[edit] Mount devices with label name

Add the following configuration and the devices will be mounted automatically to /media/<label-name>,if hal provides the label name

File: /etc/ivman/IvmConfigBase.xml
<ivm:Option name="mountcommand" value="pmount $hal.block.device$ $hal.volume.label$" />

<ivm:Option name="umountcommand" value="pumount '$hal.block.device$'" />

More useful information can be found at http://forums.gentoo.org/viewtopic-t-443437.html

[edit] Troubleshooting

[edit] USB devices don't get detected

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.

Personal tools
In other languages