Black God

Troubleshooting QNAP Debian NAS box by setting up DHCP and TFTP servers in Ubuntu

I have QNAP TS-110 home NAS box installed with Debian Linux 6.0 (Squeeze). Recently it was broken with latest kernel update (I expect all these since it is a Testing branch). I took this opportunity to learn more on recovery of QNAP. Martin Michlmayr maintains nice documents to get the recovery done. It has instructions to restore the image. Thanks, Martin.

To complement this document, I am writing this post. In Martin’s document it is assumed that user has fair knowledge of setting up DHCP and TFTP servers. But I am not so (I am a desktop Linux guy!). Here I am writing complete instructions on recovery process which includes DHCP and TFTP server setup on Ubuntu 10.10 (Beta). The basic purpose of this post is as a reference for myself in future.

The purpose of DHCP server is to allocate IP Address to QNAP server. TFTPD is for transferring recovery image to QNAP.

What is the trouble I faced?

Recently I run “# apt-get update && apt-get upgrade”, which brought new kernel and flashed. After update, I restarted the system. But.. oops.. the system did not come up!!! The status LED blinks RED and GREEN alternatively. I don’t have TTL Serial adapter to get debug console. Right now I don’t even have keyboard and mouse ( I use laptop only ). As a learning process I thought of doing a recovery. Here is how I did it.

Preparing recovery image

Recovery image can be any of the following. You can select as per your requirement. I assume that you have backup of flash partitions in your workstation. In my case it is Ubuntu. So run these command in your workstation.

Case 1. Factory installed QNAP firmware – You should have backed up before installing Debian as explained here.

In this case run the following command to make a recovery image.

$ cat mtd0 mtd4 mtd5 mtd1 mtd2 mtd3 > F_TS-110_qnap

Case 2. Debian Installer – In this also you should have backed up before installing Debian as explained here. And also download linux kernel and initrd images from this debian repository. Run the following commands to create installer image.

$ dd if=kernel of=kernel.pad ibs=2097152 conv=sync

$ cat mtd0 mtd4 mtd5 kernel.pad initrd.gz mtd3 > F_TS-110_di

Case 3. Working Debian System image - In this case, you should have run the following command from running Debian system periodically to create backup of this working Debian linux.

$ cat /dev/mtdblock0 /dev/mtdblock4 /dev/mtdblock5 /dev/mtdblock1 /dev/mtdblock2 /dev/mtdblock3 > F_TS-110_debian

The recovery image file name should start with specific QNAP model number. In my case it is F_TS-110. You can identify your model number with following command.

$ strings mtd4 | grep bootp_vendor_class

In this case I am restoring the Debian installer to start installing Debian again (F_TS-110_di).

Setting up TFTP Server in Ubuntu

I go for quick command to get it done.

$ sudo apt-get install tftpd

$ sudo vi /etc/xinet.d/tftp

Create above mentioned file with below content.

service tftp {

protocol = udp

port = 69

socket_type = dgram

wait = yes

user = nobody

server = /usr/sbin/in.tftpd

server_args = /tftpboot

disable = no

}

$ sudo mkdir /tftpboot

$ sudo chown -R nobody /tftpboot

$ sudo chmod -R 777 /tftpboot

$ sudo service xinetd restart (or) $ sudo /etc/init.d/xinetd restart

Copy the image to be restored (F_TS-110_di) to /tftpboot directory.

Setting up DHCP Server in Ubuntu

Installing the DHCP Server –

$ sudo apt-get install dhcp3-server

Configuring interface – Set the network interface in Ubuntu used for DHCP. In my case it is wireless card, so it is “wlan0″. In wired LAN case it may be eth0, eth1…

$ sudo vi /etc/default/dhcp3-server

I have just configured the follwing in this file.

INTERFACES=”wlan0″

Configuring DHCP server parameters –

$ sudo vi /etc/dhcp3/dhcpd.conf

Ensure that following are set properly apart from other default values – In my case IP Address of Ubuntu is 192.168.0.100. For QNAP, 192.168.0.103 is allocated.  Set the subnet and mask value also according to it. Note down the MAC address (00:08:xx:xx:xx:f0 in this case) of QNAP from a sticker behind the server (You can also note down from /var/log/syslog file once DHCP server started. QNAP will send DHCPDISCOVER message to Ubuntu). Enter right filename, which is nothing but our recovery image.

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.1 192.168.0.10;

}

host ts110 {
hardware ethernet 00:08:xx:xx:xx:f0;
filename “F_TS-110_qnap”;
fixed-address 192.168.0.103;
next-server 192.168.0.100;
}

Restart the DHCP server –

$ sudo service dhcp3-server restart (or) $ sudo /etc/init.d/dhcp3-server restart

Now you should have both DHCP and TFTP servers running on Ubuntu.

Pushing Debian installer to QNAP

Power on the QNAP server while keep pressing the reset button (at rear side, use small pin to do it). Keep pressing this button after starting the QNAP till you hear two consecutive beeps. If everything goes fine, QNAP should get IP address from DHCP server and fetch debian installer image from TFTP server. It will then write the image on flash and restart itself again. Once it is booted, you will hear a single beep, which indicates that Debian installer is ready. Now connect to QNAP through the SSH terminal with IP address you assigned. Use username as “installer” and password as “install”.

Happy hacking!

References:

1. Recovery process of QNAP for Debian Linux

2. Setting up DHCP server

3. Setting up TFTP server

6 comments for “Troubleshooting QNAP Debian NAS box by setting up DHCP and TFTP servers in Ubuntu

  1. November 11, 2013 at 7:49 pm

    Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is entirely off
    topic but I had to tell someone!

  2. October 29, 2013 at 1:18 am

    Hello there I am so excited I found your blog page, I really found you by mistake, while I was searching on Google for
    something else, Anyways I am here now and would just like to say thanks a lot
    for a remarkable post and a all round exciting blog (I also love the theme/design), I don’t have time to go through it all
    at the minute but I have saved it and also added in your RSS feeds, so when I
    have time I will be back to read a great deal more, Please do keep
    up the great work.

  3. June 18, 2013 at 10:02 am

    Hmm is anyone else having problems with the pictures on this blog
    loading? I’m trying to find out if its a problem on my end or if it’s the blog.
    Any feedback would be greatly appreciated.

  4. Seoapex1
    October 11, 2011 at 1:22 pm

    Compare Forex Market

    Webnomics Technologies is a Web Development and outsourcing company providing affordable design and development services.(Forex Trading ) Webnomics technologies has their expertise in Forex Market and travel industry which provide most latest Forex Trading, Forex Broker and updates. Webnomics Technologies also have etravel services for the one Click Trips booking. Webnomics technologies has a software development department to provide Modern Software.Top Forex Deal, Comparison Forex Market
    http://www.compareforexmarket.com

Leave a Reply

Your email address will not be published. Required fields are marked *