Author Topic: HDD Activity led (kind of)  (Read 3293 times)

Offline darth_llamah

  • Newbie
  • *
  • Posts: 10
  • Karma: +2/-0
    • View Profile
HDD Activity led (kind of)
« on: November 06, 2013, 09:51:15 am »
Here's quick'n'dirty way to have a HDD activity led (tested on romanrm's headless debian but should work also for other images).
Note: if you are logged in as root don't use sudo

1. Install required package (with dependencies):
Code: [Select]
sudo apt-get install sysstat-this will install required iostat binary

2. Add followin lines to /etc/rc.local before "exit 0
Note: substitute sysfs led name for the one you want to use- default led settings
Note: root permissions required- /etc/rc.local is a system file
Code: [Select]
echo none > /sys/class/leds/yellow\:pg04\:led4/trigger
iostat -z -d 1 sda | sed -u -e '1d' -e 's/Device.*/0/' -e 's/sd.*/255/' -e '/^$/d' > /sys/class/leds/yellow\:pg04\:led4/brightness &
3. Reboot and enjoy :)

General notes:
In this case iostat will poll storage devices (sda, mmcblk* etc.) once per second so led won't blink as fast as it happens in a laptop or a pc.

Accoding to top iostat uses no more than 0.4% cpu in my case (cubieboard a10, 1GHz max, performance governor).

It should be possible to use led triggers instead of brightness but I couldn't make them to work (I still have much to learn)

Better way would be to make this a system service (but I still have to learn how to write LSB-compliant scripts).

Based on this thread (archlinux arm)
« Last Edit: November 06, 2013, 09:59:26 am by darth_llamah »