Thecus N2100 Debian Etch Halt & LED Issues

Because there’s not much to do in the evenings deep in darkest Yorkshire, I have been entertaining myself recently by installing Debian GNU Linux on a Thecus N2100 NAS box. I used these excellent instructions as a starting point, but there are a few configuration issues left unresolved after following them which can actually be fixed. The contents of this post will mean nothing to just about everyone, but I’m posting it on the off-chance that there might be at least one other individual in the world who might want to use the information contained herein. I’m also quite pleased that I managed to figure it out.

The default 2.6.18 kernel in Debian Etch doesn’t support the halt command on the N2100, forcing the device into a perpetual reboot cycle, and the only way to safely power off the box is to `shutdown now` (which actually seems to call `telinit 1`, switching to single-user mode) and then pull the power cord out. Elegant this is not.

Fortunately we can work around this problem by using the i2c bus to kill the power. Here’s how:

  1. `# aptitude install lm-sensors` to get i2cset installed.
  2. Edit /etc/init.d/halt so that line 64 onwards looks like this:
    log_action_msg "Will now halt"
    # Make sure this next line is commented out
    #halt -d -f $netdown $poweroff $hddown
    
    # Thecus N2100 poweroff hack:
    # This device refuses to poweroff neatly
    # and reboots instead but we can work
    # around this by cutting power via the
    # i2c bus.
    
    # Don't actually attempt to poweroff,
    # but write to wtmp etc
    halt -d -f $netdown $poweroff $hddown -w
    
    # Check that i2cset is available
    if which i2cset > /dev/null
        then
        # Cut power to N2100
        i2cset -y 0 0x60 0x08 0x03 b
    fi

Et voilà: working poweroff. There’s very probably some reason why you shouldn’t do it this way, so don’t blame me if your N2100 bursts into flames because you used my horrible hack. An alternative method is to use etch-backports to get a 2.6.22+ kernel, which halts properly, but if you want to keep your system as a pure stable installation you need to alter the halt init script.

It’s also possible to use i2cset on boot to kill off the otherwise permanently flashing orange LED on the front panel, which is nice if you have to share a room with the thing. Stick the following script in /etc/rc.local:

# Check that i2cset is available
if which i2cset > /dev/null
    then
    # Turn flashing orange LED off
    if ! i2cset -y 0 0x60 0x09 0x00 b > /dev/null 2>&1
    then
        echo "Error encountered writing to i2c bus."
        exit 1
    fi
fi

Now I need to figure out how to make the OS shutdown when I press the power button, instead of restarting, which is what it does at the moment.

[Update: just edit /etc/inittab so that ctrlaltdel triggers shutdown -h rather than shutdown -r. The power button is hard-coded to call ctrl_alt_del() in the kernel.]

[Lenny update, 2008/08/29: these techniques all still apply to the upcoming Lenny/Testing release of Debian, except you now need to #aptitude install i2c-tools to get hold of i2cset & co, which have been taken out of lmsensors and given their own package.  Lenny fixes a problem I was having with man-db, and seems generally nicer to use too.  Upgrading is a simple matter of running %s/stable/testing/g or %s/etch/lenny/g on /etc/apt/sources.list in vim, and then #aptitutde dist-upgrade.]

Leave a Reply