Skip to content

Instantly share code, notes, and snippets.

@alfonsrv
Last active April 26, 2024 22:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfonsrv/dcab31e9f995ebfe04afe2cdc0389d57 to your computer and use it in GitHub Desktop.
Save alfonsrv/dcab31e9f995ebfe04afe2cdc0389d57 to your computer and use it in GitHub Desktop.
Argon EON allow hard drive spin down with hd-idle – EON spin down idle disks

Argon EON's OLED display does not allow for tools like hd-idle to detect when drives are inactive due to constant temperature, RAID and usage checks, thus preventing spin down of the drives.

The responsible Python script is slowed down to a more senseful value using the decorator / extra bit of code below.

Simply insert the code from the Gist below in your /etc/argon/argonsysinfo.py and add @no_spinup above the following functions that already exist within the file:

  • argonsysinfo_gethddtemp
  • argonsysinfo_listhddusage
  • argonsysinfo_listraid

It should look like this then:

@no_spinup
def argonsysinfo_gethddtemp():
    ...

Optionally, you can set SPINUP_ACTIVE_CHECK_MINUTES to another value. This is how often checks occurr and has to be about 25% bigger of the timeout you set in hd-idle's monitoring service. Note that OVM should use the default power options on the disks, as mentioned everywhere when installing hd-idle.

Enjoy quiet evenings with idle disks~

#!/usr/bin/python3
# Set the amount of minutes an active check is allowed to be performed when disks are active;
# this ensures hd-idle can identify the disks as idle and spin them down after a certain time
SPINUP_ACTIVE_CHECK_MINUTES = 30
_spinup_cache = {}
def no_spinup(f):
""" Prevents disks from spinning back up for Argon's checks by acting as a ghetto-cache """
from datetime import datetime, timedelta
global _spinup_cache
def _hdds_up() -> bool:
command = 'hdparm -C /dev/sd*'
try:
status = os.popen(command).read()
status = status.split('\n')
except IOError: return False
except Exception: return True
hdds_status = [s for s in status if s and 'drive state is' in s]
return not any(hdd_status for hdd_status in hdds_status if 'standby' in hdd_status)
def func(*args, **kwargs):
fname = f.__name__
if not _hdds_up(): # at least one HDD is currently idle
if 'gethddtemp' in fname: # ensure fan does not spin up when idle
return {'/dev/sda': 0.00}
return _spinup_cache.get(fname, {})
if _spinup_cache.get('last_result') and \
datetime.now() - timedelta(minutes=SPINUP_ACTIVE_CHECK_MINUTES) > _signup_cache['last_result']:
return _spinup_cache.get(fname, {})
result = f(*args, **kwargs)
_spinup_cache[fname] = result
_spinup_cache['last_result'] = datetime.now()
return result
return func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment