31 October, 2009

Rescue Debian on QNAP TS-209

I've a QNAP TS-209 serve sitting on my home network and serving as file server, web server, etc. Thanks to the work of Martin, Debian can run on my box with only trivial effort. Just like most of the NAS, however, you can only access it via ssh/telnet unless you have serial access. If you made some silly mistake and it won't booting up properly, you will need some rescue methods. As it doesn't won't support to boot from CD/floppy, and there is no easy way to have console access, Live CD or old floppy bootdisk just doesn't help. Fortunately, the boot loader of QNAP (uBoot) support recovery mode, which will fetch a image and flash memory. This mechanism is very useful, and can be used to recover the Debian without reinstalling everything. Recovery mode is basically using tftp to download a binary image, hence, in order to use this, you must backup the correct image once you have installed the Debian. The image can be backup with the following command:


[debian-in-qnap] $ cat /dev/mtd1 /dev/mtd2 /dev/mtd3 > qnapimg.bin Once you made the image, backup it, it is the only file needed to recover the system. Note that the image is actually the linux kernel and initrd image, hence, you should redo the backup every time you upgrade kernel on the system. Now, when you need to recover the system, following the steps:
  • Setup tftp on the local network with IP address: 192.168.0.11
  • Put the qnapimg.bin under root directory of tftp
  • Start the QNAP in recocovery (shutdown, press and hold reset button, and start the system, release the reset until you hear two short beap sound
After some minutes, you system will restart using your recovery image.

No comments: