Udisks

udisks is a D-Bus daemon offering some storage related services:


 * Enumeration of storage devices, much like udev but with more details.
 * Mounting of filesystems.
 * Partition of storage devices.
 * Monitor of storage devices.
 * Configuration of storage devices.

Prerequisites
Udisks uses D-Bus and polkit, so set them up first.

Kernel
You need to activate the following kernel options:

USE flags
There are several sections on USE flags for. Each section corresponds to version of the software to be installed. Slot 0 contains udisks version 1.x. Slot 2 contains version 2.x. Choose the appropriate version accordingly.

Global
Portage knows the global USE flag  for enabling support for udisks in other packages. Enabling this USE flag will pull in automatically (default for desktop profiles):

Emerge
After setting this you want to update your system so the changes take effect:

Additional software

 * - GNOME program to partition, configure and monitor storage devices.
 * - Automatic mount of drives.
 * - Run actions on udisks events.

Configuration
Udisks uses polkit to handle permissions.

Groups
Make sure each user is the  group. Here the example user larry is used.

If  is not among the available user groups (common users, who use a window manager instead of a desktop environment), add you user to the plugdev group.

Usage
Some useful commands include:


 * - Lists all storage devices.
 * - Monitor udisks.
 * - Monitor udisks with more details.
 * - Disable polling on the given device.

In some cases the command is not found. If this is the case, try. This command have different command options than ; use the  option if assistant is required.

Python scripting
The following code is an example of listening to udisk on the system dbus for device events. We stick with udisk1 and glib style event loops in order for the code to also be able to run on a RedHat or Centos system. Otherwise use the udisk2 monitor API to just look at mount events.

The relevant udisk documentation URL for 1.0.5 (Rhel6 is at 1.0.1) is here

USB drive example
The following example is from a Gentoo system when an 8GB USB drive containing Kubuntu 14.04 installer is plugged into a USB port. It was created by dd'ing the ISO file directly to the thumb drive. shows that the 1gb or so of good stuff ended up in /dev/sdf2 while /dev/sdf1 is the free space left over. Note that the first event is the "whole drive" or partition table getting looked at.

This happens when the device notifier pops up and we have kde open the drive in the dolphin file manager.

All this happens when we do a "safely remove" in dolphin. Notice that some of the properties are already unset and we are catching exceptions in device_dump during examination

Then we get one last removal signal when we yank the thumb drive

CD/DVD media example
The use of a DVD or CDROM in an internal drive will cause only changes events to signal. Here's an example for a mount followed by an unmount of a Gentoo autobuild iso in a Centos6 VM's virtual CDROM. Notice that there are two change signals per action. The insertion shows the first event with media available and then a second event on the mount where the DeviceMountedByUid value properly matched up with our uid. Presumably the two for the removal are the unmount followed by an eject, but media shows as not being available on both so the two are indistinguishable.

-

Troubleshooting

 * udisks communicates over D-Bus, so also see the D-Bus "Troubleshooting" section.
 * udisks communicates over D-Bus, so also see the D-Bus "Troubleshooting" section.
 * udisks communicates over D-Bus, so also see the D-Bus "Troubleshooting" section.