Durkatlon
Patron
- Joined
- Aug 19, 2011
- Messages
- 414
For installs that use the AHCI driver to control the hard drives, it is not obvious how you can find out if a drive has actually spun down according to the configuration that you have set.
This post shows you how you can use the camcontrol command to find out the power state of a drive.
First you need to identify the drive you want to take a look at:
So on my system, ada0 and ada1 are my two harddrives that I'm interested in. I will inspect the power state of ada0.
Take a look at the 10th hexadecimal value in the output. If this says "FF", the drive is spinning, if it says "00" the drive is spun down. It's that easy!!
I wrote a little script that checks both of my drives every 30 seconds so I can see if they indeed fall asleep after 5 minutes like I told them to in the GUI:
Note how both drive started in a spun up state and after 9 checks (4.5 minutes) they went to a spun down state (the ZFS pool had been idle for a few seconds before I started the command).
I hope this is useful to someone out there. It beats listening with your ear glued to the drive, in the hopes of being able to hear the moment when the drive spins down.
This post shows you how you can use the camcontrol command to find out the power state of a drive.
First you need to identify the drive you want to take a look at:
Code:
nanotube# camcontrol devlist <ST1500DL003-9V16L CC32> at scbus0 target 0 lun 0 (pass0,ada0) <ST1500DL003-9V16L CC32> at scbus2 target 0 lun 0 (pass1,ada1) <USB 2.0 Flash Drive 5.00> at scbus6 target 0 lun 0 (pass2,da0)
So on my system, ada0 and ada1 are my two harddrives that I'm interested in. I will inspect the power state of ada0.
Code:
nanotube# camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - 50 00 00 00 00 40 00 00 00 FF 00
Take a look at the 10th hexadecimal value in the output. If this says "FF", the drive is spinning, if it says "00" the drive is spun down. It's that easy!!
I wrote a little script that checks both of my drives every 30 seconds so I can see if they indeed fall asleep after 5 minutes like I told them to in the GUI:
Code:
nanotube# cat standby_check #!/usr/local/bin/bash while [ 1 ] do ada0_out=`camcontrol cmd ada0 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -` ada1_out=`camcontrol cmd ada1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r -` echo "ADA0: $ada0_out -- ADA1: $ada1_out" sleep 30 done nanotube# ./standby_check ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 FF 00 -- ADA1: 50 00 00 00 00 40 00 00 00 FF 00 ADA0: 50 00 00 00 00 40 00 00 00 00 00 -- ADA1: 50 00 00 00 00 40 00 00 00 00 00 ADA0: 50 00 00 00 00 40 00 00 00 00 00 -- ADA1: 50 00 00 00 00 40 00 00 00 00 00 ^C nanotube#
Note how both drive started in a spun up state and after 9 checks (4.5 minutes) they went to a spun down state (the ZFS pool had been idle for a few seconds before I started the command).
I hope this is useful to someone out there. It beats listening with your ear glued to the drive, in the hopes of being able to hear the moment when the drive spins down.