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.

Configuration

Permissions

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 storage group.

Default mount options

It is possible to define default mount options in /etc/udisks2/mount_options.conf. Create the file if it does not already exist. The built-in defaults and some examples can be seen in /etc/udisks2/mount_options.conf.example.

The options can target specific filesystem types. For example, mount btrfs filesystems with zstd compression enabled:

# /etc/udisks2/mount_options.conf
[defaults]
btrfs_defaults=compress=zstd

Note: Lines override the corresponding built-in defaults. Make sure not to accidentally remove mount options this way.

Usage

Information

Show information about an object.

Usage: udisksctl info [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
-d, --driveDrive to get information about

To show info on all elements: udisksctl dump

For a high-level status: udisksctl status

To monitor for changes: udisksctl monitor

Mounting

Mount a filesystem.

Usage: udisksctl mount [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
-t, --filesystem-typeFilesystem type to use
-o, --optionsMount options
--no-user-interactionDo not authenticate the user if needed

Unmount a filesystem.

Usage: udisksctl unmount [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
-f, --forceForce/lazy unmount
--no-user-interactionDo not authenticate the user if needed

Encryption

Unlock an encrypted device.

Usage: udisksctl unlock [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
--no-user-interactionDo not authenticate the user if needed
--key-fileKeyfile for unlocking
--read-onlyUnlock the device as read-only

Lock an encrypted device.

Usage: udisksctl lock [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
--no-user-interactionDo not authenticate the user if needed

Loop Devices

Set up a loop device.

Usage: udisksctl loop-setup [OPTION …]

OptionDescription
-f, --fileFile to set-up a loop device for
-r, --read-onlySetup read-only device
-o, --offsetStart at <num> bytes into file
-s, --sizeLimit size to <num> bytes
--no-partition-scanDo not scan the loop device for partitions
--no-user-interactionDo not authenticate the user if needed

Delete a loop device.

Usage: udisksctl loop-delete [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
--no-user-interactionDo not authenticate the user if needed

Power Off

Safely power off a drive.

Usage: udisksctl power-off [OPTION …]

OptionDescription
-p, --object-pathObject to get information about
-b, --block-deviceBlock device to get information about
--no-user-interactionDo not authenticate the user if needed