[systemd-devel] How to spin down a disc with systemd?
Marcin Kocur
marcin2006 at gmail.com
Thu May 1 01:37:50 PDT 2014
W dniu 30.04.2014 13:02, Lennart Poettering pisze:
> On Wed, 30.04.14 01:02, Marcin Kocur (marcin2006 at gmail.com) wrote:
>
>> Hello all,
>>
>> I wrote a service /etc/systemd/system/disable-2nd-hdd.service. I
>> have 2 HDD's where one of them doesn't need to work all the time. So
>> I thought it'd be cool to shut it down after 30 minutes of
>> inactivity (the disc isn't mounted when system starts):
>> /usr/bin/hdparm -S 241 /dev/sdb
>>
>> Then I wrote a service:
>>
>> [Unit]
>> Description=Disable sdb
>> Requires=local-fs.target
>> After=local-fs.target
> These two lines are implied and hence can be removed.
My intention was to be sure that the disc is ready to be spun down.
> Note that devices are probed asynchronously, and a device not needed at
> boot is not waited for. THis means that your service might run before
> the harddisk showed up in the kernel, or possibly that your hdparm
> command is invoked before the initializating/probing/identifying of the
> hdd or its filesystems is compelted, thus possibly negating the effect
> of your command.
>
> YOu probably want to invoke your commandn with RUN from a udev rule so
> that it is run when the hw is found.
Thanks, I expected such situation, namely that disc is somehow probed or
activated AFTER I issue hdparm command which causes it wake up again.
Right. But I really expected that systemd is able to determine when the
disc is ready and I can somehow pass this in Requires= or After= keys.
My intention was to learn systemd a bit, not udev's hackish syntax ;p
--
Pozdrawiam / Greetings
Marcin Kocur █
Dane kontaktowe / Contact details: http://koci.net.pl/email
More information about the systemd-devel
mailing list