udisksctl
Manage disks and storage devices
TLDR
Show high-level information about disk drives and block devices
Show detailed information about a device
Show detailed information about a device partition
Mount a device partition and prints the mount point
Unmount a device partition
Power off a device to safely remove it
Monitor the daemon for events
SYNOPSIS
udisksctl [OPTIONS] COMMAND [ARGUMENTS]
Examples:
udisksctl info -b /dev/sda1
udisksctl mount -b /dev/sdb2
udisksctl unmount -b /dev/sdb2
PARAMETERS
--version
Displays the version of udisksctl.
--help
Displays a help message for udisksctl or a specific command.
info -b DEVICE
Displays detailed information about the specified device. DEVICE can be a path like /dev/sda1 or a UDisks object path.
mount -b DEVICE [--options OPTIONS]
Mounts the file system on the specified device. OPTIONS are comma-separated mount options (e.g., ro, noatime).
unmount -b DEVICE
Unmounts the file system from the specified device.
power-off -b DEVICE
Powers off the specified disk. This action requires that no partitions on the disk are currently in use.
unlock -b DEVICE [--new-key-fd FD]
Unlocks an encrypted device (e.g., a LUKS volume). FD is an optional file descriptor for reading the passphrase, typically 0 for stdin.
lock -b DEVICE
Locks an encrypted device, making its contents inaccessible until unlocked again.
format -b DEVICE --type TYPE [--id-label LABEL]
Formats the specified device with the given file system TYPE (e.g., ext4, vfat, ntfs). An optional LABEL can be set for the new file system.
loop-setup -f FILE [--read-only]
Sets up a loop device from a disk image FILE. The optional --read-only flag mounts the loop device as read-only.
loop-delete -b DEVICE
Deletes a specified loop device.
monitor
Monitors D-Bus signals from the UDisks service, showing real-time events related to device changes (e.g., hot-plugging, mounting).
dump
Dumps information about all objects (disks, partitions, filesystems) currently managed by UDisks.
status
Shows the general status of the UDisks service and a summary of connected devices.
log
Retrieves and displays the log messages from the udisksd daemon.
DESCRIPTION
udisksctl is a command-line tool used to interact with the UDisks D-Bus service, which provides a high-level interface for managing storage devices. It allows users and administrators to perform various operations on disks, partitions, and loop devices without directly manipulating low-level device files.
Key functionalities include retrieving detailed information about devices, mounting and unmounting file systems, unlocking encrypted volumes (like LUKS), formatting partitions, creating and deleting loop devices from disk images, and powering off physical drives.
udisksctl acts as a front-end to the udisksd daemon, leveraging D-Bus for inter-process communication and Polkit for privilege management. This design ensures that unprivileged users can perform safe operations (e.g., mounting removable media), while more sensitive actions (e.g., formatting system disks) require elevated permissions. It is commonly used in desktop environments and server systems for automated or manual disk management tasks.
CAVEATS
Most operations involving system disks or modifications (e.g., formatting, powering off) require elevated privileges, which are typically managed via Polkit rules.
udisksctl relies on the udisksd D-Bus service being active; if the service is not running, the command will fail.
Device paths like /dev/sdXN are ephemeral and can change across reboots or hot-plugging; for persistent identification, it's often more reliable to use UUIDs or PARTUUIDs, which UDisks supports.
D-BUS AND POLKIT INTEGRATION
udisksctl communicates with the udisksd daemon via D-Bus, the inter-process communication system. Permissions for operations are enforced by Polkit (PolicyKit), which allows fine-grained control over who can perform specific actions (e.g., mount a USB drive, format a hard disk) without requiring full root privileges for all users. This integration is central to its security model and ease of use in desktop environments.
DEVICE IDENTIFICATION
While /dev/sdXN paths are commonly used with udisksctl, it's often more robust to refer to devices using their persistent identifiers. For example, UDisks can identify devices by UUID (Universally Unique Identifier) or PARTUUID (Partition UUID), which remain constant even if the device's /dev path changes. Users can often pass a path like /dev/disk/by-uuid/... or /dev/disk/by-partuuid/... to udisksctl commands for greater reliability.
HISTORY
The UDisks project, and subsequently udisksctl, evolved as a successor to DeviceKit-disks.
DeviceKit aimed to provide a hardware abstraction layer, but its functionality was later merged into UDisks (for storage devices) and udev (for general device management).
udisksctl was introduced to provide a more modern and consistent command-line interface for disk management, leveraging the D-Bus system for communication with the udisksd daemon. Its development is closely tied to desktop environments like GNOME and KDE, which utilize UDisks for auto-mounting and device discovery, but it is also a fundamental tool for server administrators.