Debian Jessie on LS-CHLv2

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search

NOTE: Work in progress.

This page documents how to install Debian Jessie on LS-CHLv2.

Instructions may be applicable also to other Buffalo hardware, although I do not have the availability of any (experience from others is welcome).

Main idea

  • Start the Linkstation in emergency mode
  • Boot the Debian Jessie Installer from TFTP
  • Install Debian Jessie with the Debian installer
  • Perform some post-installation cleanup

Differently from previous how-tos, this guide suggests to abandon the stock Buffalo kernel (2.6.22.18) and move to the ARM Debian Jessie default kernel (3.16.0-4-kirkwood). The Debian kernel supports the LS-CHLv2 hardware natively via udev/sysfs and standard gpio kernel modules. At present, however, integration with userspace functions is still incomplete: for example, the device does not power off when the power switch is turned to the "off" position.

Installation steps

Disclaimer: this procedure worked for me, but I cannot guarantee it will work for others. You'll follow this guide at your own risk and you'll be responsible for any permanent or transient data loss or damage to the unit.

Preparation & Backup

This procedure will wipe off the HDD data partition contents. You should backup any data still present on the LS-CHLv2 before proceeding.

Preparing for TFTP provisioning

  • On a PC or laptop install "tftpd". On a Debian based system:
sudo apt-get install tftpd
  • Edit /etc/xinetd.d/tftpd as follows:
service tftp
{
  protocol        = udp
  port            = 69
  socket_type     = dgram
  wait            = yes
  user            = nobody
  server          = /usr/sbin/in.tftpd
  server_args     = /var/lib/tftpboot
  disable         = no
}
  • Download uImage and rename it to uImage.buffalo
  • Download uInitrd, rename to initrd.buffalo (double check the name!)
  • Move both uImage.buffalo and initrd.buffalo to /var/lib/tftpboot directory (create it if it doesn't exist)
  • Assign to the PC/Laptop the address 192.168.11.1/255.255.255.0

Now the PC/Laptop is ready to serve the downloaded files to the Linkstation.

Booting the Debian Jessie installer

In order to enter EM mode the disk must be made unbootable. To achieve this, one can delete (or better, rename) the files in the /boot partition of the Linkstation hard disk. To be able to do this you should be able to gain root access to the Linkstation, a procedure that is explained elsewhere.

Once done:

  • Connect the Linkstation to the Laptop/PC with a direct LAN cable.
  • Turn off and on again the Linkstation. Given it's not able to boot from the HDD it should enter EM mode and the power LED should be blinking red
  • Press the function key. The LS enters TFTP boot mode and the LED becomes blinking blue
  • The Linkstation takes IP address 192.168.1.150/255.255.255.0, connects to the TFTP server you've installed and requests the file you've downloaded and places into the TFTP provisioning directory. You can check that the files are actually requested and downloaded from the tftp log.
  • The LS now boots Debian and, once done, the power led should become blue
  • Disconnect the direct cable and connect it to the local network. The Linkstation shoud get the IP address from your DHCP server

Starting the Debian Jessie installer

  • Connect to the Linkstation:
ssh installer@linkstation-ip-address
  • password is "install"
  • you enter straight to the Debian installer, ready to proceed with the Debian Jessie installation!

Installation

Installation is guided by the Debian installer.

LinkstationJessieInstall.png

At the step "Download installer components" select the "partman-ext3" component, which allows to choose ext3/ext4 filesystems in the partitioning phase.

LinkstationJessiePartitioning.png

This is the partitioning scheme which I adopted. I kept the sizes of the original partitions (I have a 1TB unit) but I use ext4 instead of ext3/xfs. Partition /dev/sda1 (/boot) is kept ext2 since that is probably necessary to allow U-Boot to load the kernel.

Remember to check /etc/fstab after the installation.

Post-installation

In your /etc/hosts add the hostname and fully-qualified domain name associated to the 127.0.1.1 IP address, so that your unit knows its own fqdn:

127.0.1.1 linkstation.yourdomain.xy linkstation

Then install the required software. At a minimum, ntpd is a must.

Performance considerations

The Jessie kernel, although working, seems to eat up too many system resources. Unfortunately memory is very tight (just 64 MiB), and it looks always used up. The system is indeed usable, but probably the kernel can be better optimized. This is something I have not done yet.

Onboard hardware support

Stock Buffalo kernel (Linux linkstation 2.6.22.18 #182 Thu May 7 13:35:58 JST 2009 armv5tejl GNU/Linux) exposed GPIO hardware through a dedicated userspace interface at /proc/buffalo. Recent kernels, such as the one which ships with Debian Jessie, support LS-CHLv2 hardware natively and expose userspace interface in /sys (sysfs) through standard kernel GPIO modules.

This does not mean, however, that everything works out-of-the-box once the system is installed. Post-installation work is still necessary.

The definition file is here: http://lxr.free-electrons.com/source/arch/arm/boot/dts/kirkwood-lsxl.dtsi?v=3.16

LEDs

Once the unit has booted Jessie the power LED turns to solid blue. It is not clear to me what triggers this behaviour (suggestions welcome).

Power LED:

/sys/class/leds/lsxl:amber:info
/sys/class/leds/lsxl:blue:power
/sys/class/leds/lsxl:red:alarm

LED on the function button:

/sys/class/leds/lsxl:blue:func
/sys/class/leds/lsxl:red:func

LEDs can be turned on and off by writing 1 or 0 in the "brightness" file. Eg:

echo 1 > /sys/class/leds/lsxl:red:alarm/brightness

Ref:

Fan

In order to see the hardware:

sudo modprobe gpio-fan

4 speeds are supported: OFF (0 RPM), LOW (1500 RPM), MEDIUM (3250 RPM), HIGH (5000 RPM)

echo 0 > /sys/devices/gpio_fan/hwmon/hwmon0/fan1_target
echo 1500 > /sys/devices/gpio_fan/hwmon/hwmon0/fan1_target
echo 3250 > /sys/devices/gpio_fan/hwmon/hwmon0/fan1_target
echo 5000 > /sys/devices/gpio_fan/hwmon/hwmon0/fan1_target

To read current speed:

cat /sys/devices/gpio_fan/hwmon/hwmon0/fan1_target

Switches

Backgroud

Acting on the switches converts into input events.

Events from the switches can be dumped with:

sudo evtest /dev/input/event0

Pressing the front function button generates:

  • EV_KEY
    • KEY_OPTION

Moving the switch in the back of the unit generates:

  • EV_SW
    • SW_LID: when switched to "off"
    • SW_TABLET_MODE: when switched to "auto"

Software actions must be associated to these events in order for something to happen - see following section. In particular, the back switch is not a power cutting switch so the unit will not power off unless proper poweroff action is configured.

Associating actions to switches

This section is adapted from Debian_Wheezy_on_LS-CHLv1#Power_switch (credits to forum user vkanth for pointing it out):

triggerhappy can be used to associate actions to the switches. It is a deamon which listens to input events and runs configured actions accordingly. It can be installed via:

sudo apt-get install triggerhappy

After installation:

  • Edit file /etc/default/triggerhappy and set DAEMON_OPTS="--user root" so that it can run privileged actions (such as system shutdown)
  • Edit file /lib/udev/rules.d/60-triggerhappy.rules and comment the first ACTION. Letting this action uncommented may turn into a hangup during boot process (Note: This comes from the LS-CHLv1 howto. I've not tested whether this happens on LS-CHLv2 as well, but... better safe than sorry).

To configure triggerhappy to initiate system poweroff when the back switch is moved to "off" position:

  • Create a file specifying an action for SW_LID:
   echo "SW_LID    0    poweroff" >  /etc/triggerhappy/triggers.d/gpio_keys_poweroff.conf
  • Restart triggerhappy
  service triggerhappy restart

USB & Disk power

Not explored yet.