Skip to content

udisksctl: Add drive-set-standby command#1448

Open
xarinatan wants to merge 1 commit intostoraged-project:masterfrom
xarinatan:feature/udisksctl-drive-set-standby
Open

udisksctl: Add drive-set-standby command#1448
xarinatan wants to merge 1 commit intostoraged-project:masterfrom
xarinatan:feature/udisksctl-drive-set-standby

Conversation

@xarinatan
Copy link
Copy Markdown

Hello there!

Note: This started as an issue I was going to file, but then I realized I might as well try to actually make a patch for it, which I did, so I went ahead and turned the issue into a PR instead.

TL;DR: Can we implement a drive-set-standby (or alike) subcommand in udiskctl?

Long version:
I ran into the issue of wanting to set the standby timeout for my newly purchased harddisk, and like many before me, ran into the issue that the disk keeps running, unless I run something like hdparm -S XX /dev/sdX, which of course is not persistent. Then, as many before me probably also did, I realized I only have a few options there; Write a udev rule myself, or use some tool like Gnome Disks (which seems weird since I run KDE).

It got me thinking: why doesn't udiskctl support this? The udisks dbus backend seems to have the support already (this is what Gnome Disks uses), so it just has to be plumbed through to the udiskctl utility, which would help many people and other projects to write simple automation for it that doesn't directly mess with udev rules. If this gets implemented it would also make it easier to integrate it into KDE tooling for example.

LLM WARNING
I used Cursor (so LLMs were involved, Gemini 3 Pro and Anthropic Opus 4.5 specifically) to quickly understand the codebase and whip up a patch for this. I did not write, but did thoroughly read the code (it seems to catch errors properly and handle all cases) and locally verified it to work on my WD Red 18TB drive. Feel free to only take it as loose inspiration and create your own version from scratch; I merely want to help.

See below for the description of the patch itself:

Add a new 'drive-set-standby' command to udisksctl that allows users to set the persistent standby timeout for ATA drives via the command line.

This exposes the existing SetConfiguration D-Bus method which was previously only accessible programmatically. The configuration is stored in /etc/udisks2/<DRIVE_ID>.conf and applied automatically on drive connection (startup, hotplug, resume).

The command accepts:
--object-path/-p: Specify drive by D-Bus object path
--block-device/-b: Specify drive by device file (e.g., /dev/sda)
--timeout/-t: Standby timeout value 0-255 (required)
--no-user-interaction: Skip polkit authentication prompts

Add a new 'drive-set-standby' command to udisksctl that allows users to
set the persistent standby timeout for ATA drives via the command line.

This exposes the existing SetConfiguration D-Bus method which was
previously only accessible programmatically. The configuration is stored
in /etc/udisks2/<DRIVE_ID>.conf and applied automatically on drive
connection (startup, hotplug, resume).

The command accepts:
  --object-path/-p: Specify drive by D-Bus object path
  --block-device/-b: Specify drive by device file (e.g., /dev/sda)
  --timeout/-t: Standby timeout value 0-255 (required)
  --no-user-interaction: Skip polkit authentication prompts

This provides a user-friendly alternative to hdparm -S that persists
across reboots without requiring custom scripts or systemd services.
Copy link
Copy Markdown
Member

@tbzatek tbzatek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution and sorry it took it so long to reply.

LLM WARNING
I used Cursor (so LLMs were involved, Gemini 3 Pro and Anthropic Opus 4.5 specifically)

We've just published new contributing guidelines proposal in #1458, please make sure to read it (and feel free to comment!). In general, please just add the commit message annotation about the specific LLM used.

unless I run something like hdparm -S XX /dev/sdX, which of course is not persistent.

Many distributions provide an init script or system service to modify drive settings at startup, see e.g. https://wiki.gentoo.org/wiki/Hdparm. Of course, this conflicts with the UDisks approach and vice versa.

If this gets implemented it would also make it easier to integrate it into KDE tooling for example.

Desktop environments should never call udisksctl which is just a wrapper around D-Bus calls anyway, but rather reach out through D-Bus directly, e.g. through generated bindings.

Anyway, very nice, a useful addition! We don't often provide all functionality in udisksctl by default and features are typically added on demand, like this one.

Comment thread tools/udisksctl.c
for (l = objects; l != NULL; l = l->next)
{
object = UDISKS_OBJECT (l->data);
drv = udisks_object_peek_drive (object);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to test the presence of the org.freedesktop.UDisks2.Drive.Ata interface, i.e. udisks_object_peek_drive_ata() instead.

Comment thread tools/udisksctl.c
for (l = objects; l != NULL; l = l->next)
{
object = UDISKS_OBJECT (l->data);
drv = udisks_object_peek_drive (object);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark here, use udisks_object_peek_drive_ata() instead.

@tbzatek
Copy link
Copy Markdown
Member

tbzatek commented Jan 28, 2026

Jenkins, ok to test.

@tbzatek
Copy link
Copy Markdown
Member

tbzatek commented Apr 20, 2026

ping @xarinatan - still interested to finish this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants