Mandriva

Removable Storage VI OBSOLETE (PRE 2006)

Summary

  • Hotpluggable hardware and removable media handling
  • Chronology
  • How to debug ?
Section index - KB index

Hotpluggable hardware and removable media handling for Mandriva Linux 2005 (and later)

Starting with Mandriva Linux 2005 LE, HAL (Hardware Abstraction Library) is used extensively to handle hotpluggable hardware (like usb memory stick, digital cameras, removable hard-drives) and removable medias like CD or DVD.

Chronology

When an new device is plugged on the system, events occur in the following order (schematics can be found on here) :

  • kernel detect new hardware is plugged and call /sbin/hotplug (to load kernel module and notify interested applications) and udev (to create devices in /dev )
  • udev will signal hal daemon (hald) when devices are created/removed. udev will also apply pam console privilege on created node, allowing user physically logged on the system (in low security setting) to acces their devices without root privilege.
  • hotplug will signal hal daemon when hotplug events (hardware device plugged/unplugged) occur.
  • hald, using a set of rules, updates its system configuration view (tree based view) and send those changes in the configuration on system bus (using dbus) to listening applications. Hald also call fstab-sync to update fstab to add/remove mount point entries and create/remove mount points (in /mnt) if needed.
  • if a user is logged in a graphical environment (like KDE or GNOME), he should have GNOME Volume Manager running in background (KDE still uses gvm until KDE volume manager is complete). gvm listens to system bus events (over dbus) and is notified when hald send "hardware added/removed" events. Based on those events and its own configuration, gvm will either mount/unmount new devices (for usb memory stick or hard-drive) or start associated applications (when digital cameras is plugged).
For removable media (like CD or DVD), path is shorter :
  • hald monitors CD/DVD drive (or any other removable media drive, like ZIP drive) for new medium. If medium is inserted or ejected, event is send over dbus.
  • gnome-volume-manager listens for those events and will mount/unmount corresponding mount points accordingly. If medium is not a data medium (audio CD, video DVD), gnome-volume-manager will start user defined scripts from /etc/dynamic/user-scripts/ which will try to start application based on the current desktop environment.
For instance, if user is inserting video DVD under GNOME, totem will be used ; under KDE, kaffeine will be used.

How to debug ?

Now, the tricky part.. You plug a device and "it doesn't work !". In order to get this fixed, you need to fill bug report to the correct package, to help maintainers to understand what is the exact problem. The best way to find the right component is to use a differential diagnosis (like a medical diagnosis).

Let's try this with a removable storage device : I plugged a removable harddrive.

  • Do you see a new icon on your desktop ? if yes, everything is fine, your test is finished
  • No new icon on the desktop : check /etc/fstab to see if new mount point was added for your device. If unsure, unplug the device, check /etc/fstab, then plug your device, wait a little (10s) and check again.
    • If mount point was added and is mounted, report a bug on nautilus (for GNOME) or kdebase (KDE).
    • If /etc/fstab contains a mount point for your entry, it means gnome-volume-manager didn't mount it automatically. Check if gnome-volume-manager is running
by running in a terminal:
ps aux | grep gnome-volume-manager
and if it is configured to automount removable devices.
    • If it is, check if hal was not configured to disable automount hint (read by gnome-volume-manager) in /etc/hal/hald.conf (storage_automount_enabled_hint).
    • If it is set, make sure this hint wasn't disabled for your particular device. For that, run hal-device-manager (in hal-gnome package) and check value for this parameter for your particular device.
    • If this hint was set, it appears to be a bug in gnome-volume-manager which should be reported.
    • If this hint was not set, it was either disabled on purpose or by mistake or it could be a bug. This bug should be reported on hal package.
  • If /etc/fstab doesn't contain mount point entry, either hal didn't detect your device or didn't create mount point for it :
    • check if hald is running correctly (/etc/init.d/haldaemon status). Make sure dbus system bus is running too (it must be started before haldaemon), using /etc/init.d/messagebus status.
    • if hal is running correctly, try to monitor for hal new events using hal-device-manager : start hal-device-manager, then plug (or unplug) your device. System tree view in hal-device-manager should be modified (with a latency up to 5 or 10s).
    • if tree view doesn't change, hal didn't receive any event from hotplug or didn't knew how to deal with them. Check syslog when plugging/unplugging your device :
    • if kernel notices something, it is probably a bug in hal.
    • If not, it is either a bug in hotplug or kernel.
    • if tree view did notice the changes, it means some parameters for this device were missing or wrong. You should report a bug in hal.
When reporting bug for hal or gnome-volume-manager, you should always add "lshal" log to bug report, which is a text representation of HAL view of your system.

When testing removable media (like CD or DVD), scenario is easier :

if your medium is a data one :

  • insert medium : if it is automatically mounted (icon on desktop), everything is fine.
  • if is isn't mounted:
    • check if mount point are ok (see above for that).
    • Try manually mounting the device. If it works, it means gnome-volume-manager didn't mount it correctly.
    • You should check if hald is running correctly, as well as dbus system bus and gnome-volume-manager.
    • Also check if gnome-volume-manager is configured to automount removable media. Start hal-device-manager and check if medium is detected.
    • If everything seems ok, report a bug for gnome-volume-manager.
    • If medium is not detected by hal-device-manager, report a bug on hal.
    • you should also test when ejecting medium that it is correctly unmounted.
  • if your medium is a non data one (audio CD, video DVD) :
    • insert medium : if application is not started, check if it enabled in gnome-volume-manager configuration. If it is, run hal-device-manager to check if new medium was correctly detected :
    • if it is not detected, file a bug report on hal.
    • if it is detected by hal-device-manager, try changing the associated application with any other application. Eject and insert again your application :
    • If the new application is detected, you have found a bug in scripts used to start applications. Fill a bug on dynamic package
    • If no application is started, it is probably a bug in gnome-volume-manager you should report.
Revision / Modified: 20 May 2005
Author: Frederic Crozat

Legal and original text

KB - Removable Storage VI OBSOLETE (PRE 2006)
Version 1.6 last modified by imr on 22/10/2006 at 11:51

 


fr en

RSS

Creator: newimr on 2005/08/28 16:55
(c) Mandriva 2007
18888888