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
udisksd(8) is started on-demand by D-Bus and should not be enabled explicitly. It can be controlled through the command-line with udisksctl(1).
udisks-daemon that is started on demand and the control command is udisks.Configuration
Actions a user can perform using udisks are restricted with polkit. If the user session is not activated or present (for example, when controlling udisks from a systemd/User service), adjust polkit rules accordingly.
See https://github.com/coldfix/udiskie/wiki/Permissions for common udisks permissions for the group, and for a more restrictive example. If you are using Dolphin, you may see .
Usage
To manually mount a removable drive, for example :
$ udisksctl mount -b /dev/sdc1
To unmount:
$ udisksctl unmount -b /dev/sdc1
See for more.
Tips and tricks
Mount helpers
The automatic mounting of devices is easily achieved with udisks wrappers. See also List of applications/Utilities#Mount tools.
- bashmount — A bash script to mount and manage removable media as a regular user with udisks2.
- Note: devmon only uses udisks or udisks2 for mounting (in this order) if udevil or pmount miss the SUID permission. To remove this permission, run
chmod -s /usr/bin/udevilas root.
udevadm monitor
You may use to monitor block events and mount drives when a new block device is created. Stale mount points are automatically removed by udisksd, such that no special action is required on deletion.
Mount to /media (udisks2)
By default, udisks2 mounts removable drives under the ACL controlled directory . If you wish to mount to instead, use this rule:
Since , unlike /run, is not mounted by default as a tmpfs, you may also wish to create a tmpfiles.d snippet to clean stale mountpoints at every boot:
Mount loop devices
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.
Hide selected partitions
If you wish to prevent certain partitions or drives appearing on the desktop, you can create a udev rule, for example :
KERNEL=="sda1", ENV{UDISKS_PRESENTATION_HIDE}="1"
KERNEL=="sda2", ENV{UDISKS_PRESENTATION_HIDE}="1"
shows all partitions with the exception of sda1 and on your desktop. Note that if you are using udisks2, the above will not work as is no longer supported. Instead, use as follows:
KERNEL=="sda1", ENV{UDISKS_IGNORE}="1"
KERNEL=="sda2", ENV{UDISKS_IGNORE}="1"
Because block device names can change between reboots, it is also possible to use UUIDs (as gathered from executing the command) to hide partitions or whole devices:
Then the following line can be used:
SUBSYSTEM=="block", ENV{ID_FS_UUID}=="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX", ENV{UDISKS_IGNORE}="1"
The above line is also useful to hide multi device btrfs filesystems, as all the devices from a single btrtfs filesystem will share the same UUID across the devices but will have different SUB_UUID for each individual device.
Apply ATA settings (udisks2)
At start-up and when a drive is connected, udisksd will apply configuration stored in the file /etc/udisks2/IDENTIFIER.conf where is the value of the Drive:Id property for the drive. Currently ATA settings are supported. See for available options. These settings have essentially the same effect as those of hdparm, but they are persistent as long as the udisks daemon is autostarted.
For example, to set standby timeout to 240 (20 minutes) for a drive, add the following:
To obtain the DriveId for your drive, use
Alternatively, use a GUI utility to manage the configuration file, such as .
Troubleshooting
Hidden devices (udisks2)
Udisks2 hides certain devices from the user by default. If this is undesired or otherwise problematic, copy to /etc/udev/rules.d/80-udisks2.rules and remove the following section in the copy:
Devices do not remain unmounted (udisks)
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, power saving, or removing a drive that was not detached with before.
To disable polling for a given device, for example a CD/DVD device:
# udisks --inhibit-polling /dev/sr0
or for all devices:
# udisks --inhibit-all-polling
See for more information.
Broken standby timer (udisks2)
The udisks daemon polls S.M.A.R.T. data from drives regularly. Hard drives with a longer standby timeout than the polling interval may fail to enter standby. Drives that are already spun down are usually not affected. There seems no way to disable polling or change the interval as for udisks2 by now. See , .
However, Standby timeout applied by udisks2 seems to be unaffected. To set standby timeout via udisks, see #Apply ATA settings (udisks2).
Other possible workarounds could be setting the timeout below the polling interval (10 minutes) or forcing a manual spindown using .
NTFS mount failing
If mounting a ntfs partition fails with the error:
Error mounting /dev/sdXY at [...]: wrong fs type, bad option, bad superblock on /dev/sdXY, missing codepage or helper program, or other error
and in the kernel log with / ran as root:
ntfs: (device sdXY): parse_options(): Unrecognized mount option windows_names.
Then the problem is that udisks is trying to use the kernel ntfs driver, which does not understand this (default) mount option. For this to work the optional dependency NTFS-3G must be installed.