Difference between revisions of "HAL"

From ArchWiki
Jump to: navigation, search
(Step 2: Configure)
(Device specific policies)
Line 142: Line 142:
====Enable the noatime mount option for removable devices====
====Enable the noatime mount option for removable devices====
This will speed up file operations and also reduce wear on flash memory devices like USB sticks or SD cards.
This will speed up file operations and also reduce wear on flash memory devices like USB sticks or SD cards.
   <match key="block.is_volume" bool="true">
   <match key="block.is_volume" bool="true">
Line 158: Line 158:
You may want to disable automounting of ntfs(/or other filesystem) partitions on login.
You may want to disable automounting of ntfs(/or other filesystem) partitions on login.
Create a file /etc/hal/fdi/policy/20-disable-automount.fdi
   <match key="storage.hotpluggable" bool="false">
   <match key="storage.hotpluggable" bool="false">

Revision as of 15:43, 9 June 2009

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end


HAL (Hardware Abstraction Layer) is a daemon that allows desktop applications to readily access hardware information so that they can locate and use such hardware regardless of bus or device type. In this way a desktop GUI can present all resources to its user in a seamless and uniform manner.

About hotplugging

There are a number of things involved in 'hotplugging' and HAL is only one of them. When a new device is added, e.g. a USB drive is plugged in, the following occurs (roughly):

  • The kernel becomes aware of a new device and registers it in Template:Filename.
  • Udev creates a device node (e.g. Template:Filename), and loads the drivers/modules needed.
  • The HAL daemon is notified by D-Bus and adds the device and what it can find out about it to its database.
  • The addition of the new device is broadcast by HAL over D-Bus to whatever programs are subscribing, e.g. Thunar, which shows it as an icon in the shortcuts side panel, or Metacity/Nautilus which will add an icon to the desktop.
  • Another program listening may be a volume manager, such as thunar-volman or AutoFS, configured to automatically create mount points and mount certain types of drives, start Rhythmbox whenever an iPod is connected, etc.

HAL does not detect the hardware (kernel), manage the devices or the drivers (udev) or automount drives (volume managers). As a hardware abstraction layer, its role is more akin to a communications center, providing your applications with a clean interface to the devices. Problems with hot-plugged devices not being properly detected, usable, or mounted should be investigated, knowing that it is a long chain and there are more components involved (see 'Troubleshooting').

About volumes mount points

HAL mounts your volumes under Template:Filename. To determine what some_folder should be it uses the label of a volume or, if the volume does not have a label, it uses the volume's type (eventually followed by a number if the directory already exists), for example: Template:Filename, Template:Filename ...

To give a label to a partition you can use GParted (available in extra) or its KDE equivalent PartitionManager (available in AUR).

Also keep in mind these three common problems that stop HAL from mounting a device:

  • the directory Template:Filename must NOT exist, it will be dynamically created and destroyed by HAL
  • the device must NOT be listed in fstab, otherwise HAL will refuse to mount it
  • you must have the right to mount the device, see Permission Denied for more details

If for some reason you can't give a label to your partition you can give a fake label to HAL, you will need two things to do so:

  • $device_uuid, the uuid of the device (Template:Codeline may help you for that)
  • $fake_label, the fake label you chose

Place this into Template:Filename without forgetting to replace $device_uuid and $device_name by their values. Template:File

Install and configure HAL

Step 1: Install

The HAL daemon requires the presence of the D-Bus daemon, so we need to make sure both are installed.

# pacman -S hal dbus

Edit Template:Filename as root with your favorite editor and add dbus & hal to the DAEMONS array, for example:

DAEMONS=(syslog-ng dbus hal network netfs ...)

The DBus and HAL daemons will now load at boot time. While HAL would load dbus automatically if it wasn't already running it would not unload it properly at shutdown. Therefore to avoid any complications it is best to load DBus before HAL through your daemons array.

Or, you could start HAL manually by issuing the following command as root:

# /etc/rc.d/hal start

For D-Bus and HAL to be of any practical use, local user accounts should be members of the following groups: optical and storage. To achieve this, open a terminal and type the following commands as root:

# gpasswd -a username optical
# gpasswd -a username storage
Replace username with your actual username (e.g. johndoe).

For those group changes to take effect, you have to completely logout and login again.

Step 2: Configure

Permissions policies

Your programs communicate with HAL controlled devices through a D-Bus interface. A number of interfaces are defined, each associated with a number of methods: The storage device interface, for example, has the methods 'eject' and 'close tray' (for optical drives). In order to 'mount' a partition on a USB key, you need access to the relevant D-Bus interface ('volume' in this case).

The configuration file Template:Filename specifies HAL-specific privileges, i.e. which users have access to which interfaces. These are defined as exceptions to the overall restrictions imposed on using D-Bus interfaces, specified in Template:Filename. In short, you'll need to see that Template:Filename grants your user the right to access specific DBUS/HAL interfaces, because the D-Bus default is not to let you access them.

The default Template:Filename will contain a number of policies denying and allowing access, amongst them this default (the later of two defaults and therefore seemingly the deciding one): Template:File

In short, users are by default denied access to interfaces like Volume which has methods such as mount and unmount. This is overruled by policies allowing users of the groups 'power' and 'storage' to access their respective devices: Template:File

That's why you will want to add your user to those groups, thus reducing the number of customized configuration files. </nowiki>}}

Device specific policies

NTFS write access

The last resort
Warning: This should only be used as a last resort 'hack' if HAL is unable to properly recognize and mount (rw) ntfs drives.

If the above policy does not work (make sure you restarted hal) you can force HAL (but also all your other programs) to use the ntfs-3g driver instead of the standard ntfs driver. As root create a symbolic link from mount.ntfs to mount.ntfs-3g:

# ln -s /sbin/mount.ntfs-3g /sbin/mount.ntfs

Possible issues using this method:

  • if mount is called with the "-i" option it doesn't work
  • possible issues with the kernel ntfs module

Locale issues

Note: this shouldn't happen anymore with ntfs-3g 2009.1.1 and newer.

You may have problem with filenames containing non-latin characters. This happens because your mounthelper is not parsing the policies and locale option correctly. There is a workaround for this:

  • Remove this symlink: Template:Codeline
  • Replace it with a new bash script containing:



Enable the noatime mount option for removable devices

This will speed up file operations and also reduce wear on flash memory devices like USB sticks or SD cards. Template:File Restart dbus and hal. If you used KDE you will have to restart KDE as well (the device notifier won't get it otherwise and will stop responding altogether). This was taken from Gullible Jones' "So long, Arch" thread as a hotfix for exactly this type of breakage and is probably not the best fix (especially for machines with a large number of users), but it works.

Note: make sure you type your user name like this Template:Codeline and NOT like Template:Codeline.

Alternate Fix

If you start your window manager from .xinitrc, see suggestion 2 entries up under "IsCallerPrivileged failed".

Auto-mounting fails

Inserted CD/DVD doesn't get recognized by HAL

If inserted CDs/DVDs are not recognized by HAL (no icon on the desktop or notification), check Template:Filename and remove the lines for the optical drives.

If that does not work, it may be because your device is not "checked" for automount by HAL. I am not sure why but you may have a file under Template:Filename which should have a content similar to: Template:File If the key is set to false (it was in my case), all you have to do is to change the value of the key to true.

USB sticks and drives do not automount correctly

This sub-section is sourced from this forum page.

If you are experiencing problems with automounting USB sticks and/or drives, but do not have problems with mounting CDs or DVDs, and if you are able to manually mount the USB device in question, then you should create the file "preferences.fdi" in the folder Template:Filename and paste the following line into the file Template:File

Also, if you have GParted installed, you might need to delete Template:Filename as mentioned at the end of [1].

Also you should remove from Template:Filename lines, corresponding to usb devices which should be mounted by hal automatically.

Removing USB flash causes improper unmount

If you remove your USB flash without previously unmounting it, automatic unmount by HAL may work improperly.

You may find that corresponding records from Template:Filename is not deleted, and in nautilus device list (and also on GNOME desktop) remains link to an empty folder, where the device was previously mounted.

This may be corrected by unmounting flash drive with "lazy" parameter. To do so, you should do some tweaking:

1) Create an executable script Template:Filename with access rights 755 and the following content Template:File 2) Then you should tell HAL to run this script when you remove your usb stick. To do so, you should add to Template:Filename the following line: Template:File

3) Execute

# /etc/rc.d/hal restart

External links