You are not logged in.
I have external hdd. It stops with terrible noise after system shutdown (heads parking?), so I want to switch it off before. I use
udisksctl power-off -b /dev/sdb
Then I want to switch it off automatically during system shutdown. I have tried to make systemd unit
# ehddoff.service
[Unit]
Description=ehdd power-off
DefaultDependencies=no
Before=shutdown.target
[Service]
ExecStart=/usr/bin/udisksctl power-off -b /dev/sdb
Type=oneshot
[Install]
WantedBy=shutdown.target
It doesn't work.
# journalctl
Jun 27 04:16:59 toshibanb ehddoff[2449]: Error connecting to the udisks daemon: Error calling StartServiceByName for org.freedesktop.UDisks2: GDBus.Error:org.freedesktop.systemd1.ShuttingDown: Refusing activation, D-Bus is shutting down.
What can you advice? Is it possible to start service before D-Bus shutdown?
Last edited by Kirill Bugaev (2019-07-01 06:54:04)
Offline
Offline
Thanks for replay, Jason.
Can you describe more precisely what do you mean?
Offline
Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /usr/lib/systemd/system-shutdown/ and pass one arguments to them: either "halt", "poweroff", "reboot" or "kexec", depending on the chosen action. All executables in this directory are executed in parallel, and execution of the action is not continued before all executables finished.
Offline
Jason, I thought it means executables in folder /usr/lib/systemd/system-shutdown/ start before actual shutdown, i.e. in last turn, just before electricity off, so D-Bus should be already shutdown. Am I wrong?
I have mdadm.shutdown only in this folder. I have tried to add bash script, smth like
#!/bin/bash
/usr/bin/logger TEST1
But TEST1 doesn't appear in system journal after reboot.
Offline
Put an executable script in there that uses hdparm -Y to power off the disk.
Offline
seth, it works. thanks.
But I get a problem with shutdown when I have added script in /usr/lib/systemd/system-shutdown/. It freezes (I waited about minute).
So I prefer use systemd unit. Shutdown is a few seconds longer.
Last edited by Kirill Bugaev (2019-07-01 07:16:08)
Offline
So is this (still) solved (by using hdparm in the systemd unit)?
Offline
seth, yes of course.
Offline