Stop HDD after X minutes of inactivity

Moderators: mdrjr, odroid

Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Mon Apr 16, 2018 5:07 pm

Hi!

I would like to instruct my ODROID HC1 units to stop the hard drives after X minutes of inactivity and spin them back up on demand. What is the proper way to achieve this? Or does the HC1 do this by default? If yes, where can I change the number of minutes of inactivity?

Thank you!
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby odroid » Mon Apr 16, 2018 6:22 pm

User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Mon Apr 16, 2018 6:26 pm

I've made progress by adding this line to /etc/rc.local:
Code: Select all
hdparm -B 127 -S 241 /dev/disk/by-uuid/e83869fe-e23a-404d-b6fc-86ec44077156


"-B 127" puts the drive into a level which allows spindown but still keeps it performant.
"-S 241" tells it to spin down after 30 minutes

Full doc here:
https://wiki.archlinux.org/index.php/hdparm#Power_management_configuration

Disk ID can be found with:
Code: Select all
sudo blkid


Now all I have to figure it out is how to test if this actually works and the HDD spins down after 30 minutes...
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Mon Apr 16, 2018 6:51 pm

Is there a physical way to tell if the HDD is spun down and sleeping? I'm thinking that maybe the green LED on the ODROID-HC1 could show the state of the attached HDD?
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby odroid » Mon Apr 16, 2018 7:14 pm

The green LED blinks only when write/read access appears.

As far as I remember, there should be a hdparm command to check the disk sleep status.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Mon Apr 16, 2018 7:22 pm

There is indeed a hdparm command, it just doesn't seem to work on my system:
Code: Select all
root@ODROID-HC1-01:~# hdparm -C /dev/sda

/dev/sda:
SG_IO: bad/missing sense data, sb[]:  70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 drive state is:  unknown
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby tkaiser » Thu Apr 19, 2018 4:38 am

Seems you're missing latest JMS578 firmware update?
tkaiser
 
Posts: 389
Joined: Mon Nov 09, 2015 12:30 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, HC1

Re: Stop HDD after X minutes of inactivity

Unread postby rooted » Thu Apr 19, 2018 5:48 am

Un4Seen wrote:Is there a physical way to tell if the HDD is spun down and sleeping? I'm thinking that maybe the green LED on the ODROID-HC1 could show the state of the attached HDD?
Do you feel vibrations?
User avatar
rooted
 
Posts: 5567
Joined: Fri Dec 19, 2014 9:12 am
Location: Gulf of Mexico, US
languages_spoken: english
ODROIDs: C1, C1+, C2
XU3 Lite, XU4
N1
VU7+
HiFi Shield 2
Smart Power (original)

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Thu Apr 19, 2018 2:26 pm

@rooted:

:) Well, that's the thing.. the HC1 units are stacked and I can only touch the top HDD (1 out of 8). See image:

Cluster01_512.jpg
Cluster01_512.jpg (79.78 KiB) Viewed 493 times


But even with that one the vibrations are barely felt.

Anyway, I tried addding the following line to /etc/rc.local:
Code: Select all
hdparm -B 127 -S 241 /dev/disk/by-uuid/e83869fe-e23a-404d-b6fc-86ec44077156


This line is supposed to make the HDDs spin down after 30 minutes of inactivity... but I had problems. Some (or maybe all - not sure) of the disks kept spinning up, spinning down, spinning up, spinning down infinitely. Maybe it's because of how GlusterFS is accessing them...

@tkaiser:
What is this "JMS578 firmware update" and how can I get it?
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby odroid » Thu Apr 19, 2018 5:07 pm

Refer this WiKi page to check the JMS578 firmware revision history.
https://wiki.odroid.com/odroid-xu4/soft ... _fw_update

Today, we've released another update to support the SATA hot-plug.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Stop HDD after X minutes of inactivity

Unread postby joerg » Thu Apr 19, 2018 5:45 pm

Hi with some hard discs as e.g. my WD Red, hdparm don't work. I use a tool named hd-idle, can be downloaded here: http://hd-idle.sourceforge.net/
joerg
 
Posts: 803
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, espaƱol
ODROIDs: C1, C1+, C2

Re: Stop HDD after X minutes of inactivity

Unread postby tkaiser » Thu Apr 19, 2018 11:18 pm

Easy check if hdparm is not working and you can't check physical behaviour:
Code: Select all
smartctl -a /dev/sda


If you get a result immediately the disk is awake otherwise sleeping.
tkaiser
 
Posts: 389
Joined: Mon Nov 09, 2015 12:30 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, HC1

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Fri Apr 20, 2018 2:04 am

Code: Select all
root@ODROID-HC1-01:~# smartctl -a /dev/sda
smartctl 6.5 2016-05-07 r4318 [armv7l-linux-4.14.29+] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sda: Unknown USB bridge [0x152d:0x0578 (0x105)]
Please specify device type with the -d option.

Use smartctl -h to get a usage summary


Perhaps because it's a SATA drive, not a USB drive?
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby tkaiser » Fri Apr 20, 2018 8:42 pm

Un4Seen wrote:
Code: Select all
root@ODROID-HC1-01:~# smartctl -a /dev/sda
smartctl 6.5 2016-05-07 r4318 [armv7l-linux-4.14.29+] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/sda: Unknown USB bridge [0x152d:0x0578 (0x105)]
Please specify device type with the -d option.

Use smartctl -h to get a usage summary


Perhaps because it's a SATA drive, not a USB drive?


Of course it's an USB drive but the patch to support JMS578 (the USB-to-SATA adapter) landed only in smartmontools 6.6 (sorry, forgot that). So it's currently
Code: Select all
smartctl -d sat -a /dev/sda


That's one of the advantages of SATA over USB: no such hassles.

('-d sat' --> SAT --> https://en.wikipedia.org/wiki/SCSI_/_ATA_Translation. This is necessary to get SMART through USB with modern USB-to-SATA bridges)
tkaiser
 
Posts: 389
Joined: Mon Nov 09, 2015 12:30 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, HC1

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Fri Apr 20, 2018 9:05 pm

Thank you, tkaiser!

Code: Select all
root@ODROID-HC1-01:~# smartctl -d sat -a /dev/sda
smartctl 6.5 2016-05-07 r4318 [armv7l-linux-4.14.29+] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD10JPLX-00MBPT0
Serial Number:    JR1004D31BXX0M
LU WWN Device Id: 5 000cca 8c8d38416
Firmware Version: 01.01H01
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    7200 rpm
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ATA8-ACS T13/1699-D revision 6
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Fri Apr 20 15:02:41 2018 EEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART Status not supported: Incomplete response, ATA output registers missing
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                (   45) seconds.
Offline data collection
capabilities:                    (0x5b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        No Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 151) minutes.
SCT capabilities:              (0x0035) SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   062    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   100   100   040    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0007   152   152   033    Pre-fail  Always       -       2
  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       596
  5 Reallocated_Sector_Ct   0x0033   100   100   005    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0
  8 Seek_Time_Performance   0x0005   100   100   040    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0012   090   090   000    Old_age   Always       -       4449
 10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       123
191 G-Sense_Error_Rate      0x000a   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       55
193 Load_Cycle_Count        0x0012   059   059   000    Old_age   Always       -       410685
194 Temperature_Celsius     0x0002   222   222   000    Old_age   Always       -       27 (Min/Max 20/48)
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0
223 Load_Retry_Count        0x000a   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.


This deifinitely spit out a ton of information, but I still don't see if the disk is spinning or not... :(
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian

Re: Stop HDD after X minutes of inactivity

Unread postby tkaiser » Fri Apr 20, 2018 10:41 pm

Un4Seen wrote:I still don't see if the disk is spinning or not... :(


Again: The smartctl call will wake up a sleeping disk. So if you have to wait a few seconds for the output you know it was sleeping, otherwise it's spinning.
tkaiser
 
Posts: 389
Joined: Mon Nov 09, 2015 12:30 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, HC1

Re: Stop HDD after X minutes of inactivity

Unread postby Un4Seen » Fri Apr 20, 2018 11:19 pm

I see! Thx!
Un4Seen
 
Posts: 145
Joined: Thu Apr 10, 2014 6:16 pm
Location: Romania
languages_spoken: english, hungarian, romanian


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 4 guests