Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Mar 2009 20:38:52 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-hackers@FreeBSD.ORG, octavian.covalschi@gmail.com
Subject:   Re: Spin down HDD after disk sync or before power off
Message-ID:  <200903041938.n24Jcqdr060153@lurza.secnetix.de>
In-Reply-To: <c0f49ea0903040910w496f4a72m3c3ce6882e55c307@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Octavian Covalschi wrote:
 > I'm looking a way to spin down HDD just right before power off. Why?
 > 
 > Because currently when I call "shutdown -p now", HDD is powered off at it's
 > full speed (7200.4) and as a result
 > I hear a noise of stopping/spinning down of HDD, and _this_ concerns me as
 > I'm afraid it can damage HDD.

You don't have to spin down a disk before powering it off.
The noise you hear is probably caused by the "autopark"
feature of the drive.  It is harmless.

 > I've tried to use rc.shutdown, but the sync of disks "wakes" HDD again...

Of course, upon halt or reboot the kernel will sync all
file systems that have been mounted read+write.

 > While searching for a solution, I noticed that reboot command/app _does_
 > spin down hdd right before it resets system power,
 > I can hear how HDD is powered on after that...

No, the reboot command doesn't do that.  It's probably your
BIOS that resets the devices.

 > 2nd thing is I cannot find "halt.c" file, i wanted to take a look how it
 > does it... although I'm up to date it's not not in
 > /usr/src/sbin

halt(8) is a hardlink to reboot(8).
Look at src/sbin/reboot.

By the way, the syncing does not happen in halt(8).  At the
time the kernel syncs the disks, no processes are running
anymore, not even init(8).  You can't do anything from
userland at this point.  If you want to insert a spin-down
for your disks, you will have to modify the kernel.  You
have to install an event handler for "shutdown_post_sync".
See the boot() function in src/sys/kern/kern_shutdown.c
for details about the kernel's shutdown sequence.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"Python is an experiment in how much freedom programmers need.
Too much freedom and nobody can read another's code; too little
and expressiveness is endangered."
        -- Guido van Rossum



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903041938.n24Jcqdr060153>