Debian Wheezy on LinkStation LS421DE

/ 2018-01-06 17:09

Disclaimer:
THE FOLLOWING PROCEDURE WILL CAUSE ALL OF YOUR DATA TO BE LOST. YOU HAVE BEEN WARNED!

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 https://tohenk.wordpress.com/2014/11/11/opening-stock-firmware-of-linkstation-ls421de/.

Install debootstrap:

$ cd ~     $ wget http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.64~bpo70+1_all.deb     $ dpkg -i --force-all debootstrap_1.0.64~bpo70+1_all.deb     

Prepare the tools by issuing commands:

$ mkdir ~/lsmod     $ cd ~/lsmod     $ wget https://github.com/tohenk/linkstation-mod/archive/master.zip     $ unzip master.zip     $ 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=http://kartolo.sby.datautama.net.id/debian     PACKAGES=     $ vi scripts/debootstrap-rootfs.cfg     

Run debootstrap:

$ ./scripts/debootstrap-rootfs.sh --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 https://github.com/tohenk/linkstation-mod/archive/master.zip     $ unzip master.zip     $ 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/ls400-133en.zip firmware/     $ unzip firmware/ls400-133en.zip     

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=172.16.1.4     NETWORK_NETMASK=255.255.255.0     NETWORK_GATEWAY=172.16.1.1     NETWORK_DNS=172.16.1.1     NETWORK_DOMAIN=ntlab.net     #INITRD_TEMP_ROOT="0x811"     #INITRD_ROOT="0x901"     INITRD_ROOT="0x802"     $ vi scripts/debootstrap-combine.cfg     $ sudo ./scripts/debootstrap-combine.sh rootfs/rootfs_wheezy_armhf_141112.tar.gz rootfs/initrd_wheezy_armhf_141112.tar.gz firmware/ls400-133en     

Unpack Buffalo kernel image:

$ sudo ./scripts/unpack-image.sh 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/unpack-rootfs.sh 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 https://github.com/tohenk/linkstation-mod/raw/master/lsmonitor/lsmonitor.tar.gz     $ 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.

Advertisements

Shared via Inoreader