This page is deprecated. Please use the installer instead.
Manually unpacking a tar ball of Debian on QNAP TS-41x
This page describes how to manually unpack a tar ball of Debian 5.0 (lenny) for the QNAP TS-41x class devices, i.e. QNAP TS-410, TS-410U, TS-419P and TS-419U. 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.
For this procedure, you'll need a QNAP TS-41x device with one or more hard drives, a USB stick with 1 GB and an SSH client.
Before you start, please ensure that your Ethernet cable is connected to eth0 (i.e. the first Ethernet port) rather than eth1 (the second Ethernet port). On the TS-419, Ethernet port numeration differs between the QNAP firmware and Debian. On Debian, eth0 is the lower (and not the upper) connector!
Preparing the hard drive
If you have previously installed the QNAP firmware to disk, you have to remove all disks before starting your TS-41x device. Now start your QNAP device and wait for it to boot. After a while you 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. On the TS-419P, you can easily find out when to connect by waiting for the IP address to be displayed on the LCD. The username is
admin and the password is
First of all, put your SATA disks back into your TS-41x and make sure you put them into the device in the right order, i.e. hdd1 first, then hdd2, etc. Then put the USB into the QNAP and wait for the QNAP firmware to mount the stick. Presumably, it's formatted with VFAT which won't work for us. So unmount the stick and format it:
umount /share/external/sdi1 mke2fs -T ext2 /dev/sdi1 mount /dev/sdi1 /share/external/sdi1
Now you can download a tar ball of Debian lenny and extract it:
cd /share/external/sdi1 busybox wget http://people.debian.org/~tbm/ts-219/lenny/base.tar.bz2 tar -xjvf base.tar.bz2
On the QNAP TS-41x, 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:
cd /share/external/sdi1/root ubootcfg -b 0 -f /dev/mtdblock4 -o uboot.orig busybox wget http://people.debian.org/~tbm/ts-41x/lenny/fix-mac sh fix-mac ubootcfg -b 0 -f /dev/mtdblock4 -o uboot.new
Let's make a backup of the QNAP firmware from flash:
cat /dev/mtdblock0 > mtd0 cat /dev/mtdblock1 > mtd1 cat /dev/mtdblock2 > mtd2 cat /dev/mtdblock3 > mtd3 cat /dev/mtdblock4 > mtd4 cat /dev/mtdblock5 > mtd5
Before we enter the Debian chroot, let's copy the network configuration over:
cp /etc/resolv.conf /share/external/sdi1/etc/
And let's generate udev rules for the network that work with your device:
busybox wget http://people.debian.org/~tbm/ts-41x/lenny/gen-udev-rules sh gen-udev-rules
Let's enter the Debian system on USB disk to prepare the SATA disk:
cd /tmp unset LANG unset LC_ALL unset LC_CTYPE mount -t proc none /share/external/sdi1/proc mount -o bind /dev /share/external/sdi1/dev chroot /share/external/sdi1 cd /dev MAKEDEV sda sdb sdc sdd
Now you have to partition and format your SATA disks. You can use
fdisk to partition them. The RAID and LVM2 tools are available but make sure to generate a valid
/etc/mdadm.conf configuration file if you want to use RAID. Finally, you should format the partitions with ext2/3.
After you've formatted your disks, you can mount the root filesystem:
mount /dev/whatever /mnt
Unpack the tar ball to the disk:
cd /mnt apt-get install bzip2 tar -xjvf /base.tar.bz2
Now you have to fix a few things with the tar ball. First of all, change the configuration of qcontrol:
rm /mnt/etc/qcontrol.conf ln -s qcontrol/ts41x.lua /mnt/etc/qcontrol.conf
Copy the network udev rules file over:
mv /root/70-persistent-net.rules /mnt/etc/udev/rules.d/
/mnt/etc/fstab and adapt it to your partition layout.
Now we're done with the disk and can unmount it:
Now we have to obtain the Debian files that have to be written to flash:
mkdir /root/debian cd /root/debian wget http://people.debian.org/~tbm/ts-41x/lenny/mtd1.bz2 wget http://people.debian.org/~tbm/ts-41x/lenny/mtd2.bz2 bzip2 -d mtd*
We have to unpack the initramfs and change the root device:
mkdir i cd i zcat ../mtd2 | cpio -i rm -f conf/conf.d/resume
conf/param.conf and replace the root device with the device where you keep the root filesystem. Note: if you use LVM, you have to use the format
/dev/mapper/foo-bar! Something like
/dev/foo/bar will not work.
OK, let's create the new initramfs:
find . | cpio --quiet -o -H newc > ../new-initrd cd .. rm -rf i gzip -9 new-initrd dd if=new-initrd.gz of=new-initrd.gz.padded ibs=9437184 conv=sync
Now write the Debian kernel and ramdisk to flash:
cat mtd1 > /dev/mtdblock1 cat new-initrd.gz.padded > /dev/mtdblock2
Leave the chroot and unmount the USB stick:
exit umount /share/external/sdi1/proc umount /share/external/sdi1/dev umount /share/external/sdi1
Now remove the USB stick and restart the machine:
Put the USB in your PC and make a backup of the
mtd files from
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:
What to do now
You now have a working system. There are a few things you should do, though:
- change the root password
- add normal user accounts
regenerate the SSH key (since the private key is included in the base system on my web page) by running:
rm /etc/ssh/ssh_host* ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N "" ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
/etc/apt/sources.listand use a Debian mirror close to you and then type:
ntpdate pool.ntp.orgto make sure the clock is always up-to-date; otherwise attempts to install new packages might fail due to GPG verification errors (for the first time, you'll probably have to setup the clock manually using the
upgrade your system using
apt-get dist-upgradeto make sure you have the latest updates.
change the timezone with
setup locales with
/etc/hostnameto change the hostname.
Download the GPG key I use to sign the kernel repository so you won't get any warning from
gpg --keyserver pgp.earth.li --recv-keys 68FD549F gpg --export -a 68FD549F | apt-key add -
- Email me at firstname.lastname@example.org and let me know that you installed Debian on your TS-41x -- since Debian on the TS-41x is work in progress, I'd like to be able to let you know of important updates.
Go back to my Debian on QNAP TS-41x page.