# hdd noise on "shutdown -p now"



## octix (Mar 3, 2009)

Hi everyone.

I'm a little concerned about a noise my hdd makes when I'm shutting down(shutdown -p now) laptop... Apparently it's powered off too sudden and I'm afraid that this would damage it. 

I think windows slows down or stops hdd 1st, and only after that laptop is powered off. 

Does anyone have the same problem?

Thank you in advance.


----------



## Djn (Mar 3, 2009)

Given that they're supposed to handle power cuts gracefully, I doubt anything done during a software power-off could harm it.


----------



## octix (Mar 3, 2009)

It sounds like hardware power-off. 
At it's full speed HDD is powered off and I get that "unhealthy" noise.


----------



## trev (Mar 3, 2009)

I'm fairly certain that 'shutdown -p' uses the BIOS ACPI function to turn off the machine. There is no safer way and this _is_ how Windows does it


----------



## octix (Mar 3, 2009)

I guess then, windows does some additional work... 

I'll try to play with "atacontrol spindown".


----------



## trev (Mar 3, 2009)

octix said:
			
		

> I'll try to play with "atacontrol spindown".



It won't work; at the very least, before FreeBSD turns off the power it flushes the disk buffers which will cause your drive to spin up...


----------



## octix (Mar 4, 2009)

You're right.. it didn't work.


----------



## octix (Mar 4, 2009)

Can I execute a command after disk sync?  ataidle -s can put to sleep mode my HDD, but again.. disk sync wakes hdd..


----------



## trev (Mar 4, 2009)

I don't believe so.

Really, I don't think you'll do your laptop any harm.


----------



## octix (Mar 4, 2009)

OK, i'll try to be not so worried 

Will continue looking, though.

Thanks for your time!


----------



## octix (Mar 6, 2009)

OK. So far I've got some results. Basically  I was advised to try to patch "ata-disk.c"

--- ata-disk.c	2008-04-08 05:48:21.000000000 -0500
+++ ata-disk-spindown.c	2009-03-05 21:21:12.000000000 -0600
@@ -57,6 +57,7 @@
 static void ad_init(device_t);
 static void ad_done(struct ata_request *);
 static void ad_describe(device_t dev);
+static void ad_spindown(void *);
 static int ad_version(u_int16_t);
 static disk_strategy_t ad_strategy;
 static disk_ioctl_t ad_ioctl;
@@ -218,6 +219,14 @@

     if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE)
 	ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0);
+    
+    if (atadev->param.support.command1 & ATA_SUPPORT_STANDBY) {
+        device_printf(dev, "Trying to spindown before poweroff.\n");
+        atadev->spindown = 1;
+        ad_spindown((void *)dev);
+    } else {
+        device_printf(dev, "Cannot spindown before poweroff.\n");
+    }
 }

 static int

however, this patch seems to work only with "halt" (shutdown -h) but not with "shutdown -p"

don't know yet, why "ad_shutdown" is not called at system's poweroff...


----------



## octix (Mar 6, 2009)

trev said:
			
		

> Really, I don't think you'll do your laptop any harm.



Perhaps I wasn't able to explain _what_ kind of noise I hear.  HDD behaves the same as with "emergency unload", which is dangerous. I mean it's not just arm parking, it's more...


----------

