[ Prev ] [ Index ] [ Next ]

hal

Created Monday 23/10/2006

HAL, which is the Hardware Abstraction Layer for Linux, is a freedesktop.org library that manages the seamless identification and mounting of devices. It loads the correct drivers and creates appropriate mount mounts. The HAL library is maintained by David Zeuthen (Red Hat), see hal webcvs (freedesktop.org) and David Zeuthen blog

▨ Todo: The hal documentation should be updated to reflect the current status for :Fedora

1. Configuration

The out-of-the-box configuration covers a wide range of devices and it suitable for a bland generic configuration. The files of intererest are:

1.A. Policy configuration (FDI files)

▨ Todo: Update this section. It's out of date ("hal-system-storage-mount" doesn't exist in FC7/FC8)

The contents of the fdi directories are fall-through, so that the FDI entries in 10generic load first and the contents of FDI's in 95userpolicy load last (with the last entries overwriting the earlier ones).

Device configuration is based on particular fdi files and particular settings within those fdi files. For example, /usr/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi is used to configure removable media. This particular policy defines sections for filesystem types like cd (for iso9660), ext3, vfat and etc. Default mount options like "sync", "quiet" and etc are defined for all filesystems and other filesystem-specific sections provide mount options relevant for a particular filesystem type. E.g., the "vfat" section of the default storage policy stipulates that the encoding is UTF-8 and may specifiy a default shortname and similar.

The policy fdi's also define which scripts are invoked for mount, unmount, eject and similar. For example, a callout to the script "hal-system-storage-mount" (in /usr/share/hal/scripts) is specified for removable filesystem media.

1.B. Storage devices

Devices mounted to /media, such as /media/dvdrw and etc are managed by the storage-policy.fdi configuration. In it's out-of-the-box form, the storage-policy.fdi (90defaultpolicy for FC3 and 95userpolicy for FC4) ensures that removable devices like usb CF, cd, dvds and etc are correctly identified and mounted to /media. However, their naming scheme is a bit bland and, for example, usb disk storage will mount to something like /media/usbdisk1.

There are 2 options here: either write a .fdi file for the specific device and set attributes (such as storage.policy.desired_mount_point) or use the rules for storage devices as defined in the standard policy.

For example, the standard storage policy will create a mount point in /media with the name of the label of the device being mounted, so long as the label is not an absoluate path. E.g., a label of "public" will by default be mounted to /media/public by the standard policy. A label of "/public" will be ignored.

2. Start/Stop daemon

The hal daemon is managed by init scripts. The hald script in /etc/init.d/haldaemon is used to start and stop the hal daemon process. The hal is started in runlevels 4, 5 and 6. To stop the daemon (replace stop with start to start the hal):

bash # /etc/init.d/haldaemon start/stop

3. fstab

The hal uses gnome-mount for hot-plugged devices. Since FC5, there are no hot-plugged entries in the fstab(1) . The device management and configuration rules are derived from the FDI's in /usr/share/hal/fdi. FC3 and earlier versions used fstab-sync to update entries in the fstab.

▨ Note: Fedora Core 5 uses gnome-mount(1) instead of fstab-sync for hot-plugged devices. This means thare are no (e.g., usb) fixed disks listed in /etc/fstab. In FC4 and prior fstab-sync was invoked by hal to create the fstab(5) entries.

4. Hal in FC3 versus FC4

In Fedora Core 3, the device descriptor files (called fdi files) are located in /usr/share/hal/fdi, with the user override files living in /usr/share/hal/fdi/95userpolicy. This has changed in FC4 and the location of user specified fdi files are /etc/hal/fdi/policy. In FC4, the location /usr/share/hal/fdi/95userpolicy is not used.

FC4 contains the system-delivered descriptors in /usr/share/hal/fdi, however these files should be left as they are and the user specified files added into /etc/hal/fdi/policy.

The load order for FC4 applies /etc/hal/fdi/policy after /usr/share/hal/fdi/policy and files are loaded based on their name, so that the contents of 10-policy loads before 20-policy and, within a directory, 10-file.fdi loads before 20-file.fdi, with the naming being arbitary as the loading scheme uses a lexical sorting for the files in the directory. In FC4, policy files can be added directly into the /etc/hal/fdi/policy directory or can be contained within subdirectories of that path. E.g., • /etc/hal/fdi/policy/device.fdi

Be careful in the naming in the above case. In general, it's probably best to either added the device descriptor files into subdirectories or to keep them all in the top level policy directory, but not both.

In FC3, the same directory structure applies but user policies are stored to /usr/share/hal/fdi/95userpolicy/some.fdi whilst system-delivered policies are contained within /usr/share/hal/fdi/policy.

5. Hal in FC5 versus FC4

Fedora Core 4 used fstab-sync to write entries to fstab(5). The fstab-sync script was invoked by the hal on device plugin. Starting with FC5, this is no longer the case, as Fedora now uses gnome-mount(1) for device management.

6. Policy Kit

The HAL library ships with a default policy kit, which is installed to /usr/share/hal. The PolicyKit is available through :cvs or can be viewed online via webcvs PolicyKit (freedesktop.org).

Stuart Moorfoot © 23 October 2006 foo@bund.com.au


Backlinks: :mobilephone :wifi