Debian Lenny on LS-CHLv2
This guide will explain how to install Debian GNU/Linux "Lenny" on the Linkstation Live LS-CHL (=LS) using the Debian "debootstrap" procedure. The original kernel will be preserved, as well as the original bootloader (U-Boot).
- create a Debian system with debootstrap
- replace the old filesystem with the new one
This guide will ask to open up the device case, reformat partitions, delete existing data, etc. All of these actions may void your warranty, destroy your data, etc. In general you can receive help from the community of from the Buffalo forums but bear in mind that every problem you may encounter is ultimately up to you to solve. You do it at your own risk.
This guide worked on LS-CHLv2 and LS-XHL.
This guide suggests to install the blstools instead, a small set of utilities developed for this hardware and enable some operations which would not be possible from a plain Debian install:
- turn the unit off from the on-off-auto switch
- turn unit blinking LEDs to still blue when boot is complete
- resume blinking when the unit is shutting down
- use the USB port
Please note that the Armel Debian "micro_evtd" package will NOT work on LS-CHLv2 and LS-XHL because of different hardware.
- 1 Preliminary steps
- 2 Prepare a Debian Lenny root filesystem
- 3 Installation
- 4 blstools
- 5 References
Don't update the firmware
If possible don't upgrade firmware to version 1.21 as you will not be able to easily get console access to the LS. Kernel
You are supposed to start from an "open" Stock Firmware, that is stock software that you can telnet to,
Follow this guide to get telnet root console access to the LS.
Note for firmware 1.33 (and possibly others) Busybox isn't linked to ar so the debootstrap step below will fail - fix this by executing
ln -s /bin/busybox /usr/bin/ar
Backup the LS
If you have any important data on the LS you definitely need to make a backup.
Even if you don't, you'd better take a snapshot of the vital disk partitions (first and second partition). So you will be able to easily revert to the original stock distribution. [forum post] explains how to do it.
Prepare a Debian Lenny root filesystem
This is derived from original debootstrap docs.
From the linkstation console download the Debian debootstrap utility and install it with dpkg:
wget http://launchpadlibrarian.net/26071255/debootstrap_1.0.13%7Ejaunty1_all.deb dpkg -i debootstrap_1.0.13~jaunty1_all.deb
dpkg will complain of missing dependencies. Ignore it.
mkdir debian-armel-rootfs debootstrap --verbose --arch armel lenny debian-armel-rootfs http://ftp.de.debian.org/debian
This step WILL take time. At the end you should get the following message:
I: Base system installed successfully.
Completing the debootstrap and preparing the rootfs
Most commands will be run in the chrooted environment of the newly created Debian Lenny install. In order to enter the chroot type
LANG=C chroot debian-armel-rootfs/ /bin/bash
to leave type exit.
Copy kernel modules from stock kernel
Kernel modules reside in /lib/modules/<kernel version>. Here we are using the stock kernel so we must copy them from the stock initrd to the new rootfs. This must be done from within a chrooted environment in the new system - won't work with stock software.
cp /boot/initrd.buffalo debian-armel-rootfs/tmp/ LANG=C chroot debian-armel-rootfs/ /bin/bash cd /tmp dd if=initrd.buffalo of=initrd.gz ibs=64 skip=1 gunzip initrd.gz mkdir INITRD mount -t ext2 -o loop initrd INITRD cp -R INITRD/lib/modules/126.96.36.199 /lib/modules/ umount INITRD rmdir INITRD rm initrd*
Adding missing devices
Still in the chrooted environment.
Mount the proc filesystem - it can be mounted a number of times - and run the command to create device nodes in /dev (TODO: investigate dynamic devices with udev?):
mount -t proc proc /proc cd /dev MAKEDEV generic umount /proc
This will also take some time while all device nodes are created.
Install and configure the locales. Suggestion is to install at least the en_US.UTF-8 and your native language locale (e.g. it_IT.UTF-8, de_DE.UTF-8, etc).
apt-get install locales dpkg-reconfigure locales
Edit the static filesystem table file /etc/fstab (e.g. with nano) and make it look like this (TODO: /dev/sda6):
# /etc/fstab: static file system information. # # file system mount point type options dump pass /dev/sda2 / xfs defaults 0 1 /dev/sda1 /boot ext3 ro,nosuid,nodev 0 2 /dev/sda5 none swap sw 0 0 proc /proc proc defaults 0 0 devpts /dev/pts devpts gid=4,mode=620 0 0
TODO: More: #sysfs on /sys type sysfs (rw) #/dev/ram1 on /mnt/ram type tmpfs (rw)
Edit /etc/network/interfaces to match your LAN configuration. My LS gets all information from DHCP:
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information. # We always want the loopback interface. auto lo iface lo inet loopback
# DHCP for Ethernet connection auto eth1 iface eth1 inet dhcp
# Example static IP setup: (broadcast and gateway are optional) # auto eth1 # iface eth1 inet static # address 192.168.0.42 # network 192.168.0.0 # netmask 255.255.255.0 # broadcast 192.168.0.255 # gateway 192.168.0.1
Choose a hostname and write it /etc/hostname (must be created).
Edit /etc/hosts as follows:
127.0.0.1 localhost.localdomain localhost
apt-get install openssh-server passwd root
Edit /etc/ssh/sshd_config and make sure that the following line is present and uncommented:
Prepare the rootfs archive
Clean up the installation, leave the chrooted environment and tar it up:
aptitude clean exit cd debian-armel-rootfs tar zcvf ../lenny-armel-rootfs.tgz *
Now you have a complete rootfs for Debian Lenny armel.
Removing the HDD
Turn the LS off and open the LS case. Will require patience and carefulness in order not to break the plastic notches. Take this page as a reference on how to open the case.
Remove the HDD from the Linkstation. Connect it to a Linux Desktop PC e.g with a SATA-to-USB adapter.
Installing the Debian rootfs
Let's say that the LS' HDD device will be /dev/sdg and the partitions will be /dev/sdg1, /dev/sdg2 etc. Change sdg to match your environment.
The following instructions will copy the lenny-rootfs.tgz file created on the LS on the local system, will FORMAT the second HDD partition and will create the Lenny rootfs there:
sudo -i mkdir /mnt/sdg1 mkdir /mnt/sdg2 mount /dev/sdg1 /mnt/sdg1 mount /dev/sdg2 /mnt/sdg2 cp /mnt/sdg2/root/lenny-rootfs.tgz . umount /mnt/sdg2 mkfs.xfs -f /dev/sdg2 mount /dev/sdg2 /mnt/sdg2 cp lenny-rootfs.tgz /mnt/sdg2/ cd /mnt/sdg2/ tar zxvf lenny-rootfs.tgz rm lenny-rootfs.tgz
Installing an empty initrd
Must make an empty initrd in LS' boot partition. Otherwise the stock initrd will start and runs scripts to check for a stock setup. Indeed an initrd is not needed in this Lenny installation as everything can be found on the root filesystem.
"empty initrd" means an initrd with no filesystem. It is not an empty file.
For this you need the mkimage command. (in Debian/Ubuntu just install the package uboot-mkimage).
mkdir x ; cd x find . | cpio --quiet -o -H newc > ../x2 cd .. mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -d x2 initrd.buffalo rmdir x ; rm -f x2 mv /mnt/sdg1/initrd.buffalo /mnt/sdg1/initrd.original cp initrd.buffalo /mnt/sdg1/
Unmount all partitions:
cd / umount /mnt/sdg*
Turn the HDD off and put it back into the LS.
Anyone would need these:
apt-get install sudo less usbutils bzip2 mc linuxlogo psmisc
Ntpd ensures that your Linkstation clock stays in sync with global time servers.
apt-get install ntp
As told above, blstools are a set of utilities which enable LS-CHL/XHL hardware-specific features otherwise unavailable from a plain Debian Lenny installation.
In order to install blstools you have to download the package from the blstools project page, put it on the LS and run, from the command line:
tar zxf blstools-0.1.0.tar.gz cd blstools-0.1.0 sudo ./install.sh sudo reboot
The following features are installed:
This is a daemon that is automatically started when the system boots. You don't need to call it directly.
lsmonitor stops the blue led from flashing and provides a reassuring, still blue light. Also, when you move the switch in "off" position lsmonitor initiates system shutdown (which is nice isn't it?)
Powers on and off the USB interface.
When you want to connect a USB disk to the Linkstation you should first call:
sudo /etc/init.d/usb start
and then you will be able to mount the USB drive to the desired location (generally, the device will be /dev/sdb1). Once done, in order to save power you can unmount the mounted volume and issue:
sudo /etc/init.d/usb stop
to disable the USB device.