udisks exists for regular users, root must (and is) able to live without it, I need help figuring out how.
The goal is to do exactly what
udisks power-off /dev/sdX
does without udisks. hdparm is out of question, as it is assumed that UAS (https://linux-sunxi.org/USB/UAS) is in use and ATA pass-through is broken, which is the case for many external drives (i.e. all Seagate enclosures, see https://www.smartmontools.org/wiki/SAT-with-UAS-Linux).
To physically stop the drive from spinning I have successfully employed
scsi_stop /dev/sdX
which is a part of the sg3-utils (Debian and derivatives) package. Then, to remove the drive from the system, I used
echo 1 > /sys/block/sdX/device/delete
These two steps do most of, but not all the work. The block device itself is removed and is not visible anymore, however, the drive is still visible as a USB device through lsusb, which is not the case with udisks power-off. So how do I finish it?