Martin Michlmayr
Open QNAP TS-219

This page is deprecated. Please use the installer instead.

Manually unpacking a tar ball of Debian on QNAP TS-119, TS-219 and TS-219P

This page describes how to manually unpack a tar ball of Debian 5.0 (lenny) for the QNAP TS-119, TS-219 and TS-219P. However, please note that the user-friendly user-friendly Debian installer is recommended for new installations.

Even though this procedure doesn't require a serial console, I suggest you only install Debian this way if you can make a serial console for your QNAP in case something goes wrong. Note that this procedure will replace the QNAP firmware in flash with Debian and erase all your data on your disk.

Preparing the hard drive

Start your QNAP device and login via SSH. Some time after you start your machine, you will hear a beep and a bit later you'll hear a longer beep. Wait for a few more seconds and then connect to the machine via SSH. The username is admin and the password is admin too.

Now you can start preparing your disk for Debian. First of all, you have to partition the disk. I have used the partition scheme where a separate partition is used for /home. Therefore, you need to create /dev/sda1 for the boot partition, /dev/sda2 for the root partition, /dev/sda3 as an extended partition from which swap (sda5) and home (sda6) are created. You can use a different layout but in this case you need to adapt /etc/fstab after unpacking the tar ball.

I used the following layout. There's no particular reason for using this partitioning layout. I simply used something similar to what debian-installer would create but you're welcome to use a different layout, although root has to be /dev/sda2 since this is hard-coded in the ramdisk.

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          31      248976   83  Linux
/dev/sda2              32         882     6835657+  83  Linux
/dev/sda3             883        9729    71063527+   5  Extended
/dev/sda5             883         928      369463+  82  Linux swap
/dev/sda6             929        9729    70694001   83  Linux

You have to use fdisk to partition your disk. Run fdisk /dev/sda and then remove all existing partitions (yes, this will destroy all your data, so make sure you have a backup!). You can do this with d followed by the partition number (e.g. d 6 d 5 etc). Now run p to make sure there are no partitions and write out the changes to disk with w. If you installed the QNAP firmware to disk previously, you have to restart now so the changes will take effect. After the reboot, login as admin again.

Okay, now you can go ahead and create the partitions as described above (press h if you need help to see what the commands are). In my case, I issues the following commands:

n p 1 1 +512M
n p 2 enter +6G
n e 3 enter enter
n l enter +512M
n l enter enter
t 5 82
a 1
p
w

Now you can format the drive:

mke2fs -T ext2 /dev/sda1
mke2fs -T ext3 -j /dev/sda2

Mount the disk somewhere:

mount /dev/sda2 /mnt/ext
mkdir /mnt/ext/boot
mount /dev/sda1 /mnt/ext/boot
cd /mnt/ext

Downloading and installing the Debian base system

Download the compressed base system (about 110 MB) and unpack it. This contains a basic system with a standard set of packages of Debian 5.0.3 (lenny, 2009-10-08).

busybox wget http://people.debian.org/~tbm/ts-219/lenny/base.tar.bz2
tar -xjvf base.tar.bz2

Format the remaining partitions:

mount -o bind /dev /mnt/ext/dev
chroot .
cd /dev
MAKEDEV sda
mkfs.ext3 /dev/sda6
mkswap /dev/sda5
exit
umount /mnt/ext/dev

Now we'll make a backup of the flash content:

cat /dev/mtdblock0 > /mnt/ext/root/mtd0
cat /dev/mtdblock1 > /mnt/ext/root/mtd1
cat /dev/mtdblock2 > /mnt/ext/root/mtd2
cat /dev/mtdblock3 > /mnt/ext/root/mtd3
cat /dev/mtdblock4 > /mnt/ext/root/mtd4
cat /dev/mtdblock5 > /mnt/ext/root/mtd5

We're getting close. Let's download the new flash images and write them to flash:

busybox wget http://people.debian.org/~tbm/ts-219/lenny/mtd1.bz2
busybox wget http://people.debian.org/~tbm/ts-219/lenny/mtd2.bz2
bzip2 -d mtd*
cat mtd1 > /dev/mtdblock1
cat mtd2 > /dev/mtdblock2

Debian is on disk and in flash now. Let's clean up and unmount the disk:

rm mtd*
rm base.tar.bz2
cd
umount /mnt/ext/boot
umount /mnt/ext

On the QNAP TS-21x, the MAC address is stored in two locations: the QNAP firmware will read the MAC address from a special location in flash but the u-boot configuration also contains a (different) MAC address. Debian and QNAP's recovery mode will use the MAC address from u-boot and so it will be different to what it was with the QNAP firmware. In order to avoid this problem, you can update the MAC address stored in the u-boot configuration:

ubootcfg -b 0 -f /dev/mtdblock4 -o - | sed "s/^ethaddr=.*/ethaddr=`get_mac`/" > /tmp/uboot
ubootcfg -b 0 -f /dev/mtdblock4 -i  /tmp/uboot

Finally, restart the machine:

reboot
exit

Boot the system

Your machine will start Debian from disk now. After about 2 minutes, you should hear a beep and the status light will become green. You can now connect to Debian via SSH. Note that the user name is root rather than admin now and that the password is root too! There are no normal users yet. The RSA key of the host is:

ae:60:d5:ba:ec:35:62:75:b8:06:5e:a7:e5:30:86:fd

What to do now

You now have a working system. There are a few things you should do, though:

Go back to my Debian on QNAP TS-21x page.

If you find this site helpful, you're welcome to make a donation.