« Previous | Next»

Thecus N2100: Testing a new kernel. Or the Installer. Or Revert. Or Recover.

Posted by coldtobi | 15 Aug, 2008, 10:09

Because of personal experience, it is good to test a kernel prior flashing it: It ould happen, that the Thecus won't boot with a new kernel. I learned this the hard way.

But how to test it? The trick is, to the kernel into RAM and execute it from there.
This howto will show all the steps necessary to testdrive a kernel.

By the way, these instructions are also good for other uses: For example,

  • if you need a recovery/rescue system, (the debian installer is fine for that purpose.)

  • if you prefer to run the debian installer from RAM, (for tests, or if you don't wan't to reflash your current firmware)
  • if you want to uninstall debian and revert to the original firmware.
  • have a backup-kernel handy. ("Known-Good-Kernel")

Best of all, this is done completely in RAM. So just "pull the plug" to revert to the old state.

Update: Please also read this article for some updates.

(Please note, that I assume some Unix knowledge in this article. I do not
advise Linux novices to install debian on their NAS. I tested the steps layed out in this article, but this how-to might contain errors that will render your NAS unusable. So if you follow any instructions on this site, you acknowledge that there is no warranty. Especially the author cannot be held responsible. Read all the instrcutions before beginning -- you might miss important informations. )


Here are the basic steps:

  1. Prepare the PC

  2. Get/Extract the files to test

  3. Load the files & test



for this how-to, you need or put on the shopping list:


To get the kernel loaded via Ethernet, Thecus' Bootloader -- RedBoot -- uses a protocol named tftp. So we need a tftp-server installed on the PC.

For Linux, you can install atftpd, which need almost no configuration. For Windows, there is also some software, but I guess you'll gonna have to ask your favorite search engine for it and how to set it up. ;-)

For Linux and other Unixes, install the package and then create the directory /var/lib/tftpboot . This directory is the "server directory", and will host the files we will test later.

atfptd is started via inetd. You don't need to manually start it.

Getting the Files

Depending on the usage scenario, the files you need are different. Lets take a look a the scenarios laid out before.

Scenario #1 Testing a (new) kernel

NOTE: This is only for updating to a newer release, like from 2.6.24 to 2.6.25. As debian is sharing some files while updating within releases, you'll need a different approach for maximum safety. (like having a backup kernel)

For testing the kernel, this assumes that you have already a working (debian) installation on your NAS. Testing a kernel implies, that you will install a new one. 

Debian will install a new kernel into the flash by default. So the first step is to disable this. Take a look at /etc/kernel-img.conf:

thecus:/etc# cat kernel-img.conf
# Kernel image management overrides
# See kernel-img.conf(5) for details
do_symlinks = yes
relative_links = yes
do_bootloader = no
do_bootfloppy = no
do_initrd = yes
link_in_boot = yes

#postinst_hook = flash-kernel

If the "postinst_hook" (red line) is not commented out, the kernel will be flashed automatically after each update. So make sure the "#" is present ;-)

After you are sure that it won't be flashed, install the kernel as you also would do. (As already noted:Please be careful when installing the same version of the kernel could mess around with the kernel module @ /lib/modules/2.6.xx.)

After you made sure, that it won't reflash your kernel, you have to install the new kernel-package (using apt-get, aptitude or like). This will generate the required files: The kernel and -- most important -- the initrd. The initial RAM-Disk for booting the kernel. 

We'll need the both files, and we have to look in /boot: The kernel (vmlinuz-"version") and the corresponding ram-disk (initrd.img-"version"):

Copy them to the /var/lib/tftpboot direcotory on your PC.

Scenario #2 Rescue System and "Dry-Run" installation of Debian

For the rescue scenario, download the debian installer image. Like as you if you wanted to install Debian. (See Thecus N2100 Installation HowTo, Part 2) The file you are looking for is n2100.bin

As we cannot use the encrypted file, it has to be deciphered and untared:

openssl enc -d -des -in n2100.bin -out upgrade.tar.gz -K 7A9816A4C275D557 -iv 0 -nosalt -nopad

tar xzf upgrade.tar.gz

(When I did this, tar exited with an error messge. However it turned out, that everything is perfectly fine, so you safely can ignore this error. At least if the files are there...)

The files extracted from the archive are initrd and vmlinuz. Copy them to /var/tftpboot.

Scenario #3. Return to the original firmware.

This is basically the same as #2. But this time, you need to get the original firmware from thecus.com. Download the firmware version, and decrypt them as in scenario #2. Get the file and do the same as you would do in 2

This also gives you two files: the ramdisk and the kernel. (ramdisk.arm and zImage). Copy them to /var/lib/tftpboot. on your PC.

(By the way, this could also give you an opportunity to downgrade your firmware version, as this effecifly bypassed any checks. Handle with care.)

Ready. Set. Go.

Now that you got the files, copy them to /var/lib/tftpboot. Make sure, that the file permissions are set up properly: To be sure, make it at world-readable.

Now, enter RedBoot as described here. The first step after telneting into the bootloader is to set up everything it needs to know to load the files over ethernet: (please make sure to fill in the IP-Adresses according your setup)

ip_address -l <ip_address_Thecus>
ip_address -h <ip_address_PC>

To load the kenel and RAM-Disk into the NAS, use the following lines:

load -r <initrd-filename> -b 0x00800000
load -r <vmlinux-filename> -b 0x00200000

Make sure to insert the right filesnames. (The ones previously extracted).

If something goes wrong, examine the error message. There might also be a log-file on your PC, like /var/log/aftp, which might offer some more hints. Aftpd can also run in the foreground to see whats happening.

After that, it is time to run the kernel:

exec -c "console=ttyS0,115200 root=<read_update> initrd=0xa0800000,42M mem=128M@0xa0000000"
(By the way, if you have more than 128MByte RAM installed in the Thecus, you replace the 128 in mem=128M@0xa0000000 with something larger, like "mem=256M@0xa0000000" for 256. (But don't overdo it. I have 512M, but if I used 512, the kernel did not boot (or I was to inpatient).
Update: On newer debian kernels, root=<your_real_root_dev> (example: root=/dev/md0, at the time I wrote this howto, it was root=/dev/ram0

Installing to flash

After testing and finding out that everything works perfectly, you can flash your new kernel to make it persistent. If not already installed, get theflash-kernel package installed. After that, a simple




will flash the last installed kernel – hopefully the one just tested. (See the man page for details and other options). After this command finished, the new kernel is stored in the non volatile memory and will boot by default. That's why you should be sure that it really works.

If you want to revert to a „Thecus Firmware“, do a firmware update via the Web Interface for actual flashing. (Or just reboot to load last flashed firmware/kernel etc.)



Linux / Debian, Thecus N2100 | Comments (0) | Trackbacks (0)

Related Articles:

0 Comments | "Thecus N2100: Testing a new kernel. Or the Installer. Or Revert. Or Recover." »