Difference between revisions of "HAL"

From ArchWiki
Jump to navigation Jump to search
Line 273: Line 273:
You should be able to insert your CD/DVDs and USB devices and access them through your file manager of choice.  In Thunar and PCManFM once the device is inserted and detected, clicking on the icon will automatically mount it.  Once mounted, you can right click to umount or eject the media.
You should be able to insert your CD/DVDs and USB devices and access them through your file manager of choice.  In Thunar and PCManFM once the device is inserted and detected, clicking on the icon will automatically mount it.  Once mounted, you can right click to umount or eject the media.
====Fixes for XFCE user====
Firstly, please make sure that you have already been added to the user group "storage" and "power". Add the following lines to the file
  <policy group="storage">
    <allow send_interface="org.freedesktop.Hal.Device.Volume"/>
    <allow send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
In case you encounter problems with the "action button" to hibernate/shutdown/suspend/logoff, you can add the following lines:
  <policy group="power">
  <allow send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
  <allow send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
===Removing USB flash causes improper unmount===
===Removing USB flash causes improper unmount===

Revision as of 07:15, 25 June 2010

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text Template:Article summary end HAL (Hardware Abstraction Layer) is a daemon that allows desktop applications to readily access hardware information, to 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.

HAL functions largely overlap with udev and kernelspace functionality. Therefore, HAL is rapidly becoming obsolete in favor of udev. Currently, a small number of programs still rely on and use HAL, though development is heading toward utilizing udev as a replacement in the near future.


There are a number of factors 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 or its KDE equivalent PartitionManager (both available in extra).

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 ignore it, and subsequently, udev will not mount it
  • you must have the right to mount the device, see Permission Denied for more details

If for some reason you cannot 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)
  • $device_name, 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 D-Bus daemon to be running. Ensure both are installed:

# pacman -S hal dbus

The Template:Filename DAEMONS array must be configured to start HAL (and dbus) at boot. There are generally 2 methods for configuring this.

Method 1: Manually adding both

Add both dbus and hal to the array, with dbus preceding hal:

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

This method directs dbus to be loaded before hal.

Note: Some users have reported problems with this setup. If you also experience problems try adding hal to the array only, as in 'Method 2', excluding dbus, as by default hal is directed to automatically start DBus.

Method 2: Adding HAL only

By default, HAL will automatically load dbus if it is not already running. Using this method, add hal only:

DAEMONS=(syslog-ng hal network netfs ...)
Note: Some users report that while using Method 2, dbus will not unload properly at shutdown. If you experience this issue, try adding dbus before HAL through your daemons array (Method 1).

HAL can be manually started 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 groups optical and storage. To achieve this, use /usr/bin/gpasswd as root:

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

For the group changes to take effect, the non-root account must logout and login.

Step 2: Configure

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 will 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 is why you will want to add your user to those groups, thus reducing the number of customized configuration files.

Device specific policies

NTFS write access

Upon installing NTFS-3G, a HAL policy file will be created at Template:Filename. This will use Template:Package Official for all NTFS volumes. Simply restart HAL, and NTFS volumes should be writeable.

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

Disable Automount on login

You may want to disable automounting of ntfs(/or other filesystem) partitions on login.


Step 3: Start or re-start HAL

For your changes to take effect you need to (re)start HAL:

# /etc/rc.d/hal restart


Note: for your changes to take effect you need to restart HAL with Template:Codeline !

Mounting fails for normal users

If you receive a Permission denied or IsCallerPrivileged failed message when you try to mount a drive in Gnome, KDE or any other destop environment, you need to start your destop enviornment with ck-launch-session by changing your Template:Filename. Look for the line that starts your DE. For eg

# exec gnome-session 

and replace it with

# exec ck-launch-session gnome-session
Note: An alternative approach for solving this issue is presented in I won the struggle against hal and policykit. It also helps to correct issues with powerdown and shutdown of the system.

If you just upgraded to hal-0.5.11-7 and suddenly mounting a device stopped working for non-root users with one of these errors:

  • "PermissionDeniedByPolicy mount-removable no"
  • "PermissionDeniedByPolicy mount-removable-extra-options no"
  • "org.freedesktop.hal.storage.mount-removable no <-- (action, result)"
  • "org.freedesktop.hal.storage.mount-removable-extra-options no <-- (action, result)"

you can fix the situation by editing Template:Filename and paste the following into the <config> section: Template:File Restart dbus and hal. If you used KDE you will have to restart KDE as well (the device notifier will not 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 Fixes
  • Allowing everything (not recommended because of security constraints):
 <match user="yourusername">
     <return result="yes"/>
  • You could also:

Template:File Where USER is your username

This gives the user specified admin authority which is the same hal authority level used by the hal and root users: Template:File

Auto-mounting fails

Inserted CD/DVD does not 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.

If this does not work, try adding

<match action="org.freedesktop.halstorage.mount-removable">
<return result="yes">

to the config section of /etc/PolicyKit/PolicyKit.conf (from http://bugs.archlinux.org/task/12221 ).

If this still doesn't work, follow the guidelines in [2].

If you get an error similar to: A security policy in place prevents this sender from sending this message to this recipient, see message bus configuration file (rejected message had interface "org.freedesktop.Hal.Device.Volume" member "Mount" error name "(unset)" destination "org.freedesktop.Hal")

Try adding: Template:File

Also, make sure that your user is in the Storage group. If not, add it with sudo gpasswd -a your_user storage

Alternative Fixes to Automount Problems

This subsection was sourced from this forum page and corresponds to the error message displayed starting with "Rejected Message Send ...". Users have seen this message while using Thunar, PCManFM, and Konqueror.

A default Template:Filename file allows device manipulation to all users, only from the console. Edit the Template:Filename file by finding this section: Template:File And change the value from true to false. Then restart dbus first, then restart hal (or you can just reboot your machine).

# /etc/rc.d/dbus restart
# /etc/rc.d/hal restart

You should be able to insert your CD/DVDs and USB devices and access them through your file manager of choice. In Thunar and PCManFM once the device is inserted and detected, clicking on the icon will automatically mount it. Once mounted, you can right click to umount or eject the media.

Fixes for XFCE user

Firstly, please make sure that you have already been added to the user group "storage" and "power". Add the following lines to the file Template:File In case you encounter problems with the "action button" to hibernate/shutdown/suspend/logoff, you can add the following lines: Template:File

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

NTFS issues

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 (and 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 does not work
  • possible issues with the kernel ntfs module

Locale issues

Note: this should not 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:

  • Replace it with a new bash script containing:


  • Add a line to the pacman configuration file:


External links

A comprehensive HAL specification and introduction
An attempt to clarify the division of labor among the kernel, udev, D-Bus and HAL with links to HOWTOs and FAQs on each
A presentation of device handling