BLog

ImprintImpressum
PrivacyDatenschutz
DisclaimerHaftung
Downloads 

Daemon for stopping HD Load Cycling on macOS systems

Some Mac hard disks do not respond to hdapm - A Mac utility for setting the power management (APM) level on SATA hard drives, and in this case the only possibility to prevent excessive load cycling of the startup disk of a Mac and by this beating it to death, is to frequently write-flush a small amount of data to it. I put my C code for the small lccguard daemon on GitHub.

lccguard is a small standalone daemon, that writes a tiny string to /var/tmp/lccguard.dummy every 4 seconds, and by this way prevents the respective disk from load cycling its heads. The frequency can be adjusted:

$ lccguard -h
usage: lccguard [-p file] [-f] [-n] [-h]
 -p file    the path to the pid file [default: /var/run/lccguard.pid]
 -f         foreground mode, don't fork off as a daemon.
 -n         no console, don't fork off as a daemon - started/managed by launchd.
 -t         idle time in seconds, [default: 4 s].
 -h         shows these usage instructions.

Installation and First Start - this needs a working Xcode Installation

  1. Get the lccguard package from GitHub:
    $ git clone https://github.com/cyclaero/lccguard.git
    $ cd lccguard
  2. Compile lccguard.c:
    $ sudo mkdir -p /usr/local/bin [optional, only if /usr/local/bin does not exist]
    $ sudo clang lccguard.c -Wno-empty-body -g0 -Ofast -march=native -o /usr/local/bin/lccguard
    $ sudo strip /usr/local/bin/lccguard
  3. Place the lccguard.plist file into /Library/LaunchDaemons/lccguard.plist:
    $ sudo cp lccguard.plist /Library/LaunchDaemons/lccguard.plist
  4. Start the lccguard daemon:
    $ sudo launchctl load /Library/LaunchDaemons/lccguard.plist

From now on, the lccguard daemon is launched automatically when rebooting.

Keywords: Load-Cycle-Count, macOS, SATA-hard-drive

Copyright © Dr. Rolf Jansen - 2017-01-01 14:02:44

PROMOTION