Build your own NAS recovery

= Overview = If there is no NAS-recovery package available for your Linkstation, you may build your own.

This has been tested with
 * LS-WVL/R1 with Firmware 1.40 and 1.41

Basic steps are:
 * 1) Download and unpack the current firmware including LSupdater.
 * This step should be easy and does not require explanation.
 * 1) Unpack the kernel and initrd from the firmware package
 * See below for how to to this.
 * 1) Start an TFTP-server
 * Below find some hints about where to get a TFTP server and how to start it.
 * 1) Make the Linkstation load the files and reboot, as described elsewhere (e.g. in Revive your arm9 box from scratch)

= Unpack the kernel and initrd from the firmware package =

LSUpdater send archive to the Linkstation, but NAS-recovery requires unpacked files to be served via TFTP.

The firmware-package contains (among others):
 * initrd.img - a ZIP-file containing initrds (initial ramdisks)
 * uImage.img - a ZIP-file containing the kernels

Getting the Product-ID
To know which files to extract from initrd.img and uImage.img, you'll need the product-id of your Linkstation.

Method 1: Log into your LS
If you opened your NAS (or another one with the same hardware) for telnet or ssh and can still log in, you may get the produc-id by executing the following command on the LS: cat /proc/buffalo/firmware

The output will be something like SERIES=LinkStation PRODUCTNAME=LS-WVL(KOUGYOKU) VERSION=0.16 SUBVERSION=FLASH 0.00 PRODUCTID=0x00003008 BUILDDATE=2011/04/05 09:26:24 BOOTVER=0.25

Needless to say: the line PRODUCTID holds the product-id :-)

Method 2: Use ACP Commander
If your can still access your NAS with ACP Commander, you can use (put the correct IP-address and password into the next line, of course): java -jar acp_commander.jar -t 192.168.x.x -ip 192.168.x.x -pw password -c "cat /proc/buffalo/firmware"

Within the output clutter spy the section which looks like in Method 1.

Method 3: Lookup in LSUpdater
Otherwise: Look into the file linkstation_version.ini of the extracted firmware. There are sections like this one: [TARGET_INFO1] PID=0x00000011 KERNEL=2011/04/05 09:26:24 FILE_BOOT_APPLY=u-boot_lsxh.bin BOOT=0.21

Find the section where FILE_BOOT_APPLY contains your model name. The example above is for LS-XH.

The line PID of this section is the product-id of your device, 0x00000011 in this example.

Unpacking the file
For Linux/Unix simply use the script below.


 * initrd.img and uImage.img are password protected zip file. You need to open it with an Unzip-Programm (Winzip, 7-zip, you name it). Passwords can be found on page Examine_ARM9_Firmware_without_Updating.
 * From initrd.img extract the file initrd.buffalo
 * From uImage.img extract uImage.map
 * uImage.map contains the filenames for each product id.
 * From uImage.img extract the file matching your product id.
 * Rename this file into uImage.buffalo (or set a soft-link)

Helper script for Linux/Unix
You may copy & paste the following lines into a shell:

= Getting a TFTP-Server =

Windows
Fetch one from you favorite software side.

Linux
Several tftp servers should be available with your Linux distribution. The package names may vary. Simply choose one :-)

Please have in mind, that TFTP uses Port 69, thus the server has to be started as root.


 * tftp-server
 * is not working, since it requires file-requests to contain absolute pathes, but the Linkstation requests without path.
 * meant to be started via inetd, but can be run stand-alone
 * To start in stand-alone use

wget http://pypi.python.org/packages/source/t/tftpy/tftpy-0.5.1.tar.gz tar xzf tftpy-0.5.1.tar.gz  cd tftpy-0.5.1 export PYTHONPATH=$PWD:$PYTHONPATH python bin/tftpy_server.py --root /path/to/firmware
 * python-tftpy -- pure Python implemention
 * Can be run without installation:
 * If you are an experience Python user, you may use easy_install or pip as usual.