QNAP TS-210

The QNAP TS-210 s a NAS-device that can be run under Gentoo. This article aims to provide a guide to set up Gentoo on your QNAP TS-210 device and provide you with basic functionality.

This guide is based on the following guides "Gentoo on the QNAP TurboStation TS109/TS209" by Raúl Porcel http://dev.gentoo.org/~armin76/arm/qnap/ts209/ and Martin Michelmayer's guide "Debian on QNAP TS-210, TS-219 and TS-219P" http://www.cyrius.com/debian/kirkwood/qnap/ts-219/.

Of course their warnings also apply here:

So please read the above sources, their FAQs, and be sure you know what you are doing.

Requirements

 * A QNAP TS-210 with two Harddisks, on which you already run QFinder.
 * Another Computer from which you can access your QNAP over OpenSSH or telnet.
 * Internet connection for download of the operating system
 * A good idea probably also is a cable for serial console access as described here: http://www.cyrius.com/debian/kirkwood/qnap/ts-219/serial.html

Before you start: Backup
Make a backup of all data on the harddisks of your QNAP-device. Aditionally we need to backup the original flash partitions that will be overwritten later. To do this enable SSH access in the QNAP web interface and execute

Provide your administration password and do

Now you have saved copies of the flash partitions to your hard disk. Extract the files mtd0 to mtd5 from the hard disk and store them in a safe place. You will need them in case you want to reinstall the original software.

Overview
The installation follows the arm installation handbook http://www.gentoo.org/doc/en/handbook/handbook-arm.xml with a few important differences explained below. In particular the compilation of the kernel, preparation of an initramfs and flashing both to the flash partitions will be treated. As installation system we will use the basic Linux system by QNAP that is on the flash memory. As this Linux system does not include an mdadm package for administration of a RAID system we will first install the system on the /dev/sda harddisk. If you want to have your system on a RAID array you will have to follow a few extra steps documented below.

Getting started
Login to your QNAP device over SSH or telnet as above. Test if your internet connection is working, for example with a ping command. If yes you can continue in the installation handbook chapter 4.

Partition Table
As you will copy the kernel and initramfs to the flash memory we don't need a boot partition, though you can create one anyway. As a proposition you could create a 1G swap (/dev/sda1) partition and a 15G partition for your system on /dev/sda2. The rest of /dev/sda can then later be used for storage. Leave /dev/sdb unchanged for the moment.

Stage Information

 * The architecture is
 * CHOST: armv5tel-softfloat-linux-gnueabi
 * profile default/linux/arm/10.0

Kernel
Emerge your favourite kernel-sources, genkernel as well as the needed applications for Uboot-bootloader Then run genkernel with the preferences for kirkwood processors, of course you need to adapt the real-root parameter accordingly.

Configure the kernel as usual. Some important options are

Try to put only the drivers neccessary for boot to be compiled into the kernel and the rest as a module. The kernel image may not be too big, as it needs to fit on a flash memory of only 2MB. When the compile is finished, the following will create the file Uboot image:

Check that the image.uboot file is not larger than 2MB. If it is too big remove some compiled in options from the kernel. Now you need to enlarge the initramfs to match the size of the flash partition /dev/mtd2

Now we are ready to flash the kernel to the block devicees:

Finishing the installation
Continue with the rest of the handbook. But before you reboot be sure you configured your network properly and add SSH to the default runlevel:

If the system starts and you are able to log in, congratulations, you now have a working Gentoo system. You can now adapt it to your needs. It is definitely a good idea to store the working flash parttions on another computer for eventual later use.

If the system does not start properly, read below how to restore the original flash partitions. You can then rechroot to the Gentoo environment, try to fix things and retry.

Convert to RAID 1
If you followed the above steps, the system does not use software RAID. But you can set it up to use software RAID by using this article: Migrate_to_RAID. You shoul already have the right kernel options. To tell the QNAP to start from the RAID, you need to recreate the initramfs and flash it to memory by the same commands as above, but with real_root set accordingly.

Qcontrol
There is a package called qcontrol that provides basic functionality for the LEDs and the two buttons. To install it

Verify that /etc/qcontrol.conf is actually a copy of /etc/qcontrol/ts219.lua. And add the qcontrol script to the default runlevel:

This will set the statusled and powerled when the boot process is finished and during shutdown. Additionally it plays a beep after boot and before shutdown.

Restore the QNAP Firmware
This is adapted from http://www.cyrius.com/debian/kirkwood/qnap/ts-219/recovery.html. The idea is to redirect the QNAP via a special DHCP-server to a TFTP-server providing the backup of the flash memory and make the QNAP TS-210 download and flash it to the memory. To this end we are going to set up a dhcp and server on eth1. First of all we need to concatenate the backup files in a specific order to a file called F_TS-210_qnap:

Now lets set up the DHCP-server:

Now start the TFTP and DHCP server:

Now connect your QNAP to the eth1 port, press the reset button on the back of the QNAP, hold it and turn the QNAP on. After about 10s you hear two short beeps. The QNAP will start downloading the file and flash it to memory. Don't interrupt it until it has rebooted. This takes up to 5min. It should now start again with the flash image you provided.

Troubleshooting
To see possible errors during boot it might be usefull to set

to see logs of the boot-process in /var/log/rc.log. = See also =
 * QNAP TS-41X