Udisks

udisks provides a daemon udisksd, that implements D-Bus interfaces used to query and manipulate storage devices, and a command-line tool udisksctl, used to query and use the daemon.

Installation

There are two versions of udisks called udisks and udisks2. Development of udisks has ceased in favor of udisks2. [1]

udisksd (udisks2) and udisks-daemon (udisks) are started on-demand by D-Bus, and should not be enabled explicitly (see man udisksd and man udisks-daemon).

Configuration

Actions a user can perform using udisks are restricted with Policykit. If your session is not activated or present, configure policykit manually. The following file sets common udisks permissions for the storage group. [2]

/etc/polkit-1/rules.d/50-udisks.rules
polkit.addRule(function(action, subject) {
  var YES = polkit.Result.YES;
  var permission = {
    // only required for udisks1:
    "org.freedesktop.udisks.filesystem-mount": YES,
    "org.freedesktop.udisks.filesystem-mount-system-internal": YES,
    "org.freedesktop.udisks.luks-unlock": YES,
    "org.freedesktop.udisks.drive-eject": YES,
    "org.freedesktop.udisks.drive-detach": YES,
    // only required for udisks2:
    "org.freedesktop.udisks2.filesystem-mount": YES,
    "org.freedesktop.udisks2.filesystem-mount-system": YES,
    "org.freedesktop.udisks2.encrypted-unlock": YES,
    "org.freedesktop.udisks2.eject-media": YES,
    "org.freedesktop.udisks2.power-off-drive": YES
  };
  if (subject.isInGroup("storage")) {
    return permission[action.id];
  }
});

See [3] for a more restrictive example.

Mount helpers

Automatic mounting of devices is easily achieved with udisks wrappers. See also List of Applications#Mount tools and File manager functionality#Mounting.

Devmon

udevil includes devmon, which is compatible to udisks and udisks2. It uses mount helpers with the following priority:

  1. udevil (SUID)
  2. pmount (SUID)
  3. udisks
  4. udisks2

To mount devices with udisks or udisks2, remove the SUID permission from udevil:

# chmod -s /usr/bin/udevil
Note:

chmod -x /usr/bin/udevil as root causes devmon to use udisks for device monitoring

Tip: To run devmon in the background and automatically mount devices, enable it with devmon@.service; it takes the user name as argument: devmon@user.service. Keep in mind services run outside the session; adjust Polkit rules where appropriate, or run devmon from the user session (see Autostart).

Tips and tricks

udisks2: disable hiding of devices

Udisks2 hides certain devices from the user by default. If this is undesired or otherwise problematic, copy /usr/lib/udev/rules.d/80-udisks2.rules to /etc/udev/rules.d/80-udisks2.rules and remove the following section in the copy:

# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# Devices which should not be display in the user interface
[...]

udisks2: mount to /media

By default, udisks2 mounts removable drives under the ACL controlled directory /run/media/$USER/. If you wish to mount to /media instead, use this rule:

/etc/udev/rules.d/99-udisks2.rules
# UDISKS_FILESYSTEM_SHARED
# ==1: mount filesystem to a shared directory (/media/VolumeName)
# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName)
# See udisks(8)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

Mount an ISO image

To easily mount ISO images, use the following command:

$ udisksctl loop-setup -r -f image.iso

This will create a loop device and show the ISO image ready to mount. Once unmounted, the loop device will be terminated by udev.

Troubleshooting

udisks2: Physical eject button does not work

Tango-emblem-important.png

Tango-emblem-important.png

The factual accuracy of this article or section is disputed.

Reason: This bug may be related to GVFS instead of udisks2 (Discuss)

Ejecting discs manually does not work in udisks2 up to version 2.1.3-1 [4]. As a workaround, eject via software, or use the original udisks.

udisks: Devices do not remain unmounted

udisks remounts devices after a given period, or polls those devices. This can cause unexpected behaviour, for example when formatting drives, sharing them in a virtual machine, or removing a drive that was not detached with --detach before.

To disable polling for a given device, run:

# udisks --inhibit-polling /dev/sdX

or for all devices:

# udisks --inhibit-all-polling

See man udisks for more information.

See also