Debian Wheezy on LinkStation LS421DE | Toha’s Blog

Debian Wheezy on LinkStation LS421DE | Toha’s Blog


Installing Debian on LinkStation LS421DE to replace the Buffalo stock firmware aimed to create a full customized operating system without unnecessary software as in stock firmware.

The configuration for the following scenario described as below:

  • Using LinkStation LS421DE with armhf (arm hard float) architecture.
  • Not using raid, but adding raid partition for data partition is fully supported.
  • Currently, no vanilla kernel available. So, we are using Buffalo kernel at the moment. Vanilla kernel can be cross compiled.

The main process of Debian installation summarized as follow:

  • Creating rootfs by debootstrapping Debian on running LS421DE system.
  • Using a Linux box (Ubuntu) to prepare suitable image for LinkStation.
  • Modifying partition and installing Debian.
  • Enable lsmonitor script and customize Debian system.

Creating rootfs on running LS421DE system

You must have already a root access to the LinkStation box, if not, follow the the procedure on

Install debootstrap:

$ cd ~  $ wget  $ dpkg -i --force-all debootstrap_1.0.64~bpo70+1_all.deb  

Prepare the tools by issuing commands:

$ mkdir ~/lsmod  $ cd ~/lsmod  $ wget  $ unzip  $ cd linkstation-mod-master  

Edit scripts/debootstrap-rootfs.cfg and adjust as you need, choose closest mirror from your location. Extra packages can be specified using PACKAGES variable.

$ cat scripts/debootstrap-rootfs.cfg  ARCH=armhf  VERSION=wheezy  MIRROR=  PACKAGES=  $ vi scripts/debootstrap-rootfs.cfg  

Run debootstrap:

$ ./scripts/ --clean  

You can ommit –clean option if you don’t want to debootstrap-ing again. After debootstrap process, the rootfs archive can be found on rootfs folder:
rootfs_wheezy_armhf_yymmdd.tar.gz => hddrootfs
initrd_wheezy_armhf_yymmdd.tar.gz => initrd

Preparing Debian image for LinkStation

On Linux (Ubuntu) box, prepare the tools:

$ mkdir ~/lsmod  $ cd ~/lsmod  $ wget  $ unzip  $ cd linkstation-mod-master  

Transfer rootfs from LinkStation (replace lsbox with your real LinkStation hostname or IP address):

$ mkdir rootfs  $ scp root@lsbox:/root/lsmod/linkstation-mod-master/rootfs/* rootfs/  

Prepare LinkStation stock firmware and place it in firmware folder:

$ mkdir firmware  $ cp path-to-buffalo-firmware/ firmware/  $ unzip firmware/  

Customize scripts/debootstrap-combine.cfg (adjust HOSTNAME, NETWORK_PROTO, etc), then create hddrootfs and initrd:

$ cat scripts/debootstrap-combine.cfg  HOSTNAME=LS421DE88B  NETWORK_INTERFACE=eth1  NETWORK_PROTO=static  NETWORK_IP=  NETWORK_NETMASK=  NETWORK_GATEWAY=  NETWORK_DNS=  #INITRD_TEMP_ROOT="0x811"  #INITRD_ROOT="0x901"  INITRD_ROOT="0x802"  $ vi scripts/debootstrap-combine.cfg  $ sudo ./scripts/ rootfs/rootfs_wheezy_armhf_141112.tar.gz rootfs/initrd_wheezy_armhf_141112.tar.gz firmware/ls400-133en  

Unpack Buffalo kernel image:

$ sudo ./scripts/ firmware/ls400-133en/uImage.img out/  

Debian image for LinkStation now ready in the folder out with files hddrootfs.buffalo.updated, initrd.buffalo, and uImage.buffalo.

Modifying partition and installing Debian

Now, detach the hard disk from LinkStation and attach it to Linux box. Ensure the disk is detected and acquire the correct device node:

$ ls /dev/sd*  

I’m assumed the disk detected as /dev/sda. Next install mdadm if it’s not already installed:

$ sudo apt-get install --no-install-recommends mdadm  

Assemble raid partition:

$ sudo mdadm --assemble --scan  

Stop all raid partition:

$ sudo mdadm --stop /dev/md0  $ sudo mdadm --stop /dev/md1  $ sudo mdadm --stop /dev/md2  $ sudo mdadm --stop /dev/md101  

Remove all raid partition:

$ sudo mdadm --remove /dev/md0  $ sudo mdadm --remove /dev/md1  $ sudo mdadm --remove /dev/md2  $ sudo mdadm --remove /dev/md101  

Zero super block:

$ sudo mdadm --zero-superblock /dev/sda1  $ sudo mdadm --zero-superblock /dev/sda2  $ sudo mdadm --zero-superblock /dev/sda5  $ sudo mdadm --zero-superblock /dev/sda6  

Create filesystems:

$ sudo mkfs.ext3 /dev/sda1  $ sudo mkfs.ext4 /dev/sda2  $ sudo mkswap /dev/sda5  $ sudo mkfs.ext4 /dev/sda6  

Install Debian:

$ mkdir /tmp/sda1  $ sudo mount /dev/sda1 /tmp/sda1  $ sudo cp out/initrd.buffalo /tmp/sda1  $ sudo cp out/uImage.buffalo /tmp/sda1  $ mkdir /tmp/sda2  $ sudo mount /dev/sda2 /tmp/sda2  $ sudo ./scripts/ out/hddrootfs.updated.buffalo /tmp/sda2  

Attach back the disk to LinkStation, try pinging to test if installation was successfull. You then can SSH-ing as usual.

Enable lsmonitor script and customize Debian system

Now, the final step to customize Debian system by enabling lsmonitor init script:

$ cd ~  $ wget  $ cd / && tar -xvf ~/lsmonitor.tar.gz  

Install dependencies:

$ apt-get install smartmontools hdparm  

Enable init script:

$ update-rc.d lsmonitor defaults  

Start lsmonitor service:

$ service lsmonitor start  

Now, Debian system is complete. Next you can customize your Debian as you need.