On some (any?) new ThinkPad models, Lenovo has chosen not to add a hdd-led. E.g. on my new ThinkPad Edge E540.
Who is used to look at this led, when pc is stuck (it doesen’t change anything, but it is nice to know if it is working), will shurely miss it someday.
Under linux it is very simple to control the led, Lenovo uses as tittle on the ThinkPad logo.
You can find it as:
cat /proc/acpi/ibm/led shows how to use it:
commands: on, off, blink ( is 0-15)
Now we need a small script, that checks hdd activity and controls the led accordingly.
hdd activity can be found on:
Column 1 and 5 are listing all read and write operations. When they change, our hdd should blink.
You’ll find a python script doing this in my GitHub-Repository (tp-hdd-led.py).
it looks like this:
#!/usr/bin/python import time led = "0" def on(file): file.write(led + " on") file.flush() def off(file): file.write(led + " off") file.flush() def blink(file): file.write(led + " blink") file.flush() def get_val(line): a = line.strip(' ').split(' ') for x in range(a.count('')): a.remove('') return a def blink(): with open("/proc/acpi/ibm/led", "w") as l: off(l) time.sleep(0.4) on(l) time.sleep(0.1) if __name__ == "__main__": i = '' while True: with open("/proc/diskstats", "r") as s: time.sleep(.1) s = s.read() if s != i: blink() i = s
[Unit] Description=Enable ThinkPad LED as HDD LED DefaultDependencies=true Wants=graphical.target [Service] ExecStart=/usr/share/tp-hdd-led/tp-hdd-led.py [Install] WantedBy=multi-user.target
After installation you can start the service via:
systemctl start tp-hdd-led
and load it on every boot via:
systemctl enable tp-hdd-led