[AHCI] Spinning down ada(4) disks

With Freebsd 7 appeared the atacontrol spindown command, with the ata hard drive spindown timeout in the kernel ata driver.

Is there similar feature for ahci and ada drives ?
Or a way to achieve similar behavior ?

I've been told of a script, but I can't find it anywhere.
 
trev said:
"atacontrol spindown" works with my SATA drives in AHCI mode (FreeBSD 7.2-STABLE amd64).

Freebsd 7.2 has not the new ahci(4) driver present in 8.0.

aragon said:
Have you tried the idle and standby commands in camcontrol(8)?

How to use them ?
camcontrol spindown ada0 does not works.
camcontrol idle ada0 does not works either.

I tried camcontrol stop, but then, subsequent disk access doesn't return from kernel.
 
Tzim said:
camcontrol spindown ada0 does not works.
camcontrol idle ada0 does not works either.

Try:

Code:
camcontrol standby ada0 -t 10

Should spin the drive down after 10 seconds of idle...
 
Nope theres no standby option in camcontrol. Not on FreeBSD 8.0 RELEASE P2 system.

I know ive dug this thread up but does anyone know how todo this in FreeBSD 8 with AHCI*?

I previously used the command # atacontrol spindown <disk> <time in seconds>

Edited to add - AHCI added into the kernel so the disks use the new cam layer and appear as 'adaX'.
 
Same issue here - it appears the manpage also doesn't list a standby command.

I did manage to enable APM (Advanced Power Management) on the drives; which drives use to spindown themselves after inactivity. I successfully used these commands under FreeBSD 8-STABLE (march 2010):

camcontrol cmd ada1 -a "EF 05 00 00 00 00 00 00 00 00 60 00"

note: the 60 is the actual value in hex; 00 is lowest APM FF is highest value. I'm assuming the lower the value the sooner the drive will spindown.

To see if it worked:

camcontrol identify ada1

To disable APM:

camcontrol cmd ada1 -a "EF 85 00 00 00 00 00 00 00 00 00 00"

I'm not sure why the standby commands don't work anymore; hope they'll get introduced back to camcontrol before 8.1 releases.
 
I get this error on stable/8 while sending above command

Code:
camcontrol cmd ada1 -a "EF 05 00 00 00 00 00 00 00 00 60 00"
camcontrol: error sending command

camcontrol identify ada1
pass1: <ST31000528AS CC35> ATA-8 SATA 2.x device
pass1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
...

Code:
camcontrol cmd ada0 -a "EF 05 00 00 00 00 00 00 00 00 60 00"
camcontrol: error sending command

camcontrol identify ada0
pass0: <MAXTOR STM3750330AS MX15> ATA-8 SATA 2.x device
pass0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
...
 
"power management" doesnt work? need "advanced power management"?
is any quick hack to make ataidle work again?

Code:
camcontrol identify ada1
pass1: <ST31000528AS CC35> ATA-8 SATA 2.x device
pass1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)

protocol              ATA/ATAPI-8 SATA 2.x
device model          ST31000528AS
firmware revision     CC35
serial number         9VP0VXQK
WWN                   5000c5001532e420
cylinders             16383
heads                 16
sectors/track         63
sector size           logical 512, physical 512, offset 0
LBA supported         268435455 sectors
LBA48 supported       1953525168 sectors
PIO supported         PIO4
DMA supported         WDMA2 UDMA6
media RPM             7200

Feature                      Support  Enable    Value           Vendor
read ahead                     yes      yes
write cache                    yes      yes
flush cache                    yes      yes
overlap                        no
Tagged Command Queuing (TCQ)   no       no
Native Command Queuing (NCQ)   yes              32 tags
SMART                          yes      yes
microcode download             yes      yes
security                       yes      no
power management               yes      yes
advanced power management      no       no      0/0x00
automatic acoustic management  yes      yes     254/0xFE        254/0xFE
media status notification      no       no
power-up in Standby            yes      no
write-read-verify              yes      no      0/0x0
unload                         no       no
free-fall                      no       no
data set management (TRIM)     no
 
Your drive seems doesn't support Advanced Power Management. You may just use simple Power Management via [cmd=]camcontrol standby ada0 -t XXX[/cmd]
 
I'm switched back to ata driver.. so ataidle make spin down disks again on inactivity timer...

Is there any way to make system aware of sleeping drive? AFAIK system doesn't make account when drive sleeping for its access. Because when drive in power saving mode system gets ugly DMA transfer error message when it tries to access the fs on drive and makes queries again and again ("making request directly" message) like bad sector error... can be it short paused to access just-spinned-up drive?
 
What's wrong with 'camcontrol standby ...' that I have mentioned? Old ata(4) has too low timeout values that may cause timeouts on long spin-up.
 
getting timeouts on one of my drives (cable brand new from Asus mobo kit)
but after issuing it again it executes..

yes brand new camcontrol has better timeouts xD

Code:
camcontrol standby ada1 -t 3600
(pass1:ahcich1:0:0:0): STANDBY. ACB: e2 00 00 00 00 40 00 00 00 00 f3 00
(pass1:ahcich1:0:0:0): CAM status: Command timeout
Code:
ahcich1: Timeout on slot 0
ahcich1: is 00000000 cs 00000001 ss 00000000 rs 00000001 tfd c0 serr 00000000
ahcich1: Timeout on slot 0
ahcich1: is 00000000 cs 00000001 ss 00000000 rs 00000001 tfd c0 serr 00000000

Code:
camcontrol identify ada1
pass1: <ST31000528AS CC35> ATA-8 SATA 2.x device
pass1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)

protocol              ATA/ATAPI-8 SATA 2.x
device model          ST31000528AS
firmware revision     CC35
 
I'm unable to disable power management feature on the HDD.
Doing:

Code:
% camcontrol cmd ada0 -a "EF 85 00 00 00 00 00 00 00 00 00 00"
camcontrol: error sending command

Drive info:
Code:
camcontrol identify ada0
pass0: <WDC WD10EARS-00Y5B1 80.00A80> ATA-8 SATA 2.x device
pass0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)

protocol              ATA/ATAPI-8 SATA 2.x
device model          WDC WD10EARS-00Y5B1
firmware revision     80.00A80
cylinders             16383
heads                 16
sectors/track         63
sector size           logical 512, physical 512, offset 0
LBA supported         268435455 sectors
LBA48 supported       1953525168 sectors
PIO supported         PIO4
DMA supported         WDMA2 UDMA6

Feature                      Support  Enable    Value           Vendor
read ahead                     yes      yes
write cache                    yes      yes
flush cache                    yes      yes
overlap                        no
Tagged Command Queuing (TCQ)   no       no
Native Command Queuing (NCQ)   yes              32 tags
SMART                          yes      yes
microcode download             yes      yes
security                       yes      no
power management               yes      yes
advanced power management      no       no      0/0x00
automatic acoustic management  yes      no      254/0xFE        128/0x80
media status notification      no       no
power-up in Standby            yes      no
write-read-verify              no       no      0/0x0
unload                         no       no
free-fall                      no       no
data set management (TRIM)     no

Please suggest how to disable power management.

Thanks
 
rft said:
I'm unable to disable power management feature on the HDD.
Code:
camcontrol identify ada0
pass0: <WDC WD10EARS-00Y5B1 80.00A80> ATA-8 SATA 2.x device

Please suggest how to disable power management.

Thanks

In my experience, the only way to disable the power management on these WD Green drives is to use the wdidle3.exe utility provided by Western Digital. It's a DOS utility, which sucks, but there's instructions on how to make a boot CD for this at http://forum.synology.com/enu/viewtopic.php?f=124&t=20907 - I used it on my WD15EARS, and it worked fine.
 
  • Thanks
Reactions: rft
Something meaning a fix to ataidle or something equally acceptable

sub_mesa said:
To disable APM:

camcontrol cmd ada1 -a "EF 85 00 00 00 00 00 00 00 00 00 00"

I'm not sure why the standby commands don't work anymore; hope they'll get introduced back to camcontrol before 8.1 releases.

Just for notational purposes, my drive is
Code:
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <WDC WD5000BEVT-22A0RT0 01.01A01> ATA-8 SATA 2.x device
ada0: Serial Number WD-WX70AA9L4426
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 476940MB (976773168 512 byte sectors: 16H 63S/T 16383C)
pass0: Command Queueing enabledGEOM: new disk ada0
# ataidle /dev/ada0 gives
Code:
could not get device information: is a device attached?
ataidle: an error occurred identifying the device /dev/ada0
Which makes me feel squishy as my "193 Load_Cycle_Count" is (or was) going up at about 1/min, even under heavy HDD use.

Anyway, hopefully something comes of all of this.
 
FreeBSD 8.1-RELEASE has additional options

I just found out that camcontrol(8) in FreeBSD 8.1-RELEASE now supports the following commands:
  • idle: Put ATA device into IDLE state. Optional parameter specifies automatic idle timer value in seconds.
  • standby: Put ATA device into STANDBY state. Optional parameter specifies automatic standby timer value in seconds.
  • sleep: Put ATA device into SLEEP state. Note that the only way get device out of this state may be reset.
I haven't had the time to investigate if we can use these commands to spin down disks when the system is idle, but I will look into it soon. I someone else has more info, then please post the information in this thread.
 
bugboy said:
I just found out that camcontrol(8) in FreeBSD 8.1-RELEASE now supports the following commands:
  • idle: Put ATA device into IDLE state. Optional parameter specifies automatic idle timer value in seconds.
  • standby: Put ATA device into STANDBY state. Optional parameter specifies automatic standby timer value in seconds.
  • sleep: Put ATA device into SLEEP state. Note that the only way get device out of this state may be reset.
I haven't had the time to investigate if we can use these commands to spin down disks when the system is idle, but I will look into it soon. I someone else has more info, then please post the information in this thread.

I tried camcontrol standby in the 8.1-RELEASE, and it did spin down my SATA disks using the AHCI driver. I tried to set a 15 minute timer for standby using:

Code:
camcontrol standby ada0 -t 900
but my drives spun down immediately. However after disk access caused them to spin up, they did spin down on their own after 15 minutes.
 
Man page was not completely correct. It is already corrected in 8-STABLE. There is no idle timer in drive, only one standby timer. If you don't need to spin-down drive immediately, but after timeout, use
Code:
camcontrol idle ada0 -t 900
 
Hmm, when I initially tried camcontrol idle ada0 (without -t), it did not seem to spin-down my drive. It did not bring down power usage when measured with a Kill A Watt meter. I guess my drives were already in the idle state. However, camcontrol standby ada0 did bring down power usage, and I could hear my drive spin down.

I'd like to set up spin-down after 15 minutes of inactivity by issuing camcontrol commands to a /usr/local/etc/rc.d/ shell script. Trying to follow the advice above, how about this for a theoretical /usr/local/etc/rc.d/spindown.sh script?

Code:
#!/bin/sh

case "$1" in
start)
        /sbin/camcontrol idle ada0 -t 900
        /sbin/camcontrol idle ada1 -t 900
        /sbin/camcontrol idle ada2 -t 900
        /sbin/camcontrol idle ada3 -t 900
        /sbin/camcontrol idle ada4 -t 900
        /sbin/camcontrol idle ada5 -t 900
 
        /sbin/camcontrol standby ada0 -t 900
        /sbin/camcontrol standby ada1 -t 900
        /sbin/camcontrol standby ada2 -t 900
        /sbin/camcontrol standby ada3 -t 900
        /sbin/camcontrol standby ada4 -t 900
        /sbin/camcontrol standby ada5 -t 900
        echo "Set sata spindown to 900 seconds"
        exit 0
        ;;
stop)
        exit 0
        ;;
*)
        echo "Usage: `basename $0` {start|stop}" >&2
        exit 64
        ;;
esac
 
If you need spin down immediately - use `camcontrol standby adaX`. If you need standby after 15 minutes - use `camcontrol idle adaX -t 900` (it means: idle now, but set standby timer for 900 seconds). If you need both - `camcontrol standby adaX -t 900`. If device is already in standby - `camcontrol idle adaX -t 0` will spin it up and stop standby timer.
 
Back
Top