Debian Lenny on the NSA-220

Marvell Orion based
Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Debian Lenny on the NSA-220

Post by Mijzelf » Sun Jan 03, 2010 6:08 pm

Update 2013-12-10
This method doesn't work without modifications on firmware 3.24 and newer, because usb_key_func.sh is only called from FAT formatted sticks.

What it is
This is a Debian distro (Lenny) which will run completely from usbstick, putting aside the firmware. The firmware is untouched, when you remove the stick and reboot, the box will happily run the firmware again.
It is possible to install Lenny on harddisk, but you'll need the usbstick as bootloader.

How to install
  • Download the package here.
  • Format an usbstick (at least 256MB) ext2 or ext3 (no reiserfs). You can do this using the webinterface, using the Create External Volume button.
  • Extract the package, and put the contents on the stick. Users of firmware 2.20 or older will have to rename nsa220_check_file.fw220_and_older to nsa220_check_file.
    • The stick should (at least) contain
    • nsa220_check_file
    • usb_key_func.sh
    • usb_key_func.salted_md5sum
    • extract_me.tgz
    usb_key_func.sh should be executable. When you use the samba interface of the NAS to put the files on the stick, this is automatically done.
  • Plug the stick in the NAS, and reboot the box.
The first time it will last several minutes before the box is booted, because the Lenny package has to be extracted.
The box will use DHCP to get an IP address. Maybe the webinterface of your router can tell you which ip address is assigned. If you want a static address you'll have to edit /etc/network/interfaces (I have put an example of a static address inside.)
The default MAC address is 12:34:56:78:9a:bc. When you want another one, again, edit /etc/network/interfaces
The box is running a telnet server. There is one user configured, root with password root.
I suggest you to install sshd, and remove telnetd, when ssh has proven to work:

Code: Select all

apt-get update
apt-get install openssh-server
apt-get remove telnetd
The harddisks are not yet mounted. You'll have to install mdadm:

Code: Select all

apt-get update
apt-get install mdadm
The install script will automatically recognize and assemble your array(s). To mount them use 'mount -a' (or 'reboot'). When you've got a reiserfs system, the kernelmodule has to be loaded first:

Code: Select all

modprobe reiserfs
# let it load at boot:
echo reiserfs >>/etc/modules
The box has no NAS functions, at the moment. Install samba and/or nfsd:

Code: Select all

apt-get update
apt-get install samba
apt-get install nfs-kernel-server
Go nuts, there are more than 21000 packets available.

How to install on harddisk
The file /boot/reload.sh creates the commandline, which is read by initramfs to mount the rootfilesystem. To boot from the raidarray, extract extract_me.tgz in /mnt/md0, and edit /boot/reload.sh (on the stick)

Code: Select all

<snip>
echo Generate commandline...
# in case you want to boot from the usbstick
# CMDLINE="root=${USBDEVICE} rw"
# in case you want to boot from an raidarray
CMDLINE="root=/dev/md0 rw md=0,/dev/sda2,/dev/sdb2"
initramfs will mount the firmware to use mdadm to assemble the array.
The kernel doesn't support reiserfs, so if your harddisk is formatted reiserfs, initramfs will have to load a kernelmodule before it can mount the disk. This is currently not supported.

How it works
usb_key_func.sh is used to let the firmware start Lenny.
A modified version of fonz' reloaded.ko is used to reboot the box, with a new kernel, an initramfs and a modified commandline. This kernel boots Lenny. The firmware kernel cannot run Lenny due to wrong kernel configuration.

Known issues
You can't use the powerbutton to shutdown. Instead open a shell and use the 'halt' command.
The kernel only works after a reboot. Because of that /boot/reload.sh will first reboot the box before it reloads the kernel. /boot/reload.status is used to keep track of this.

Disclaimer
As far as I know this hack is harmless for your hardware and data. But I do not take any responsibility for damage caused by this software.
Use at own risk

tjay
Posts: 2
Joined: Fri Jan 08, 2010 12:35 pm

Re: Debian Lenny on the NSA-220

Post by tjay » Fri Jan 08, 2010 12:37 pm

great work!

is it now possible to get WOL for the box?

Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Fri Jan 08, 2010 1:03 pm

I don't think so. For WOL you need hardware support. (The networkinterface needs to be active while the box is off, and the networkinterface has to have a way to switch the box on)
*If* this hardware support is available, I believe ZyXEL would have implemented it in software. Another selling argument at hardly any cost.

tjay
Posts: 2
Joined: Fri Jan 08, 2010 12:35 pm

Re: Debian Lenny on the NSA-220

Post by tjay » Fri Jan 08, 2010 9:45 pm

fancontrol and the led patch dont work
the mounted: /mnt/firmware/sbin is empty

firmware: NSA-220 Plus V3.21(AFG.0)

Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Fri Jan 08, 2010 10:33 pm

Is there a big file AllPack.lzma in /mnt/firmware? If yes, can you try to add this code to /etc/init.d/nsa220.sh, function do_start(), after the check if fanctrl is running, and before it's started?

Code: Select all

DECOMPRESS_PATH=/usr/AllPack

if [ -f /mnt/firmware/AllPack.lzma ]; then
    if [ ! -d ${DECOMPRESS_PATH} ]; then 
        mkdir ${DECOMPRESS_PATH} 
        cd ${DECOMPRESS_PATH} 
        lzma d /mnt/firmware/AllPack.lzma -so | tar x -C ${DECOMPRESS_PATH} 
        rm AllPack.tar 
        cd / 
   fi 
   mount --bind ${DECOMPRESS_PATH}/usr/ /mnt/firmware/usr/ 
   mount --bind ${DECOMPRESS_PATH}/sbin/ /mnt/firmware/sbin/
fi
Check for syntax errors before reboot:

Code: Select all

/etc/init.d/nsa220.sh start

melhor
Posts: 5
Joined: Tue Jan 12, 2010 10:38 am

Re: Debian Lenny on the NSA-220

Post by melhor » Tue Jan 12, 2010 11:04 am

Hi!

I can't get it work. I have a NSA-220 with Firmware Version 3.22 (AFB.0)

I created the partition with ext2 via the nsa web interface. then i copied all the files (except readme and Adjustet.txt) from the zip-file to the the stick (via Samba-share), deleted the file nsa220_check_file and renamed the file nsa220_check_file.fw220_and_older to nsa220_check_file .
Rebooted the NSA by pressing the power-button on the box. But the SYS LED on the box kept blinking and i didn't have any access to the NSA, so after one hour i powered it down again. i tried it several times, but the content on the stick does not change in any way, nothing is unpacked! i also didn't receive any syslog-message during the nsa boot process.

is there something i might did wrong?

peter

Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Tue Jan 12, 2010 11:31 am

Mijzelf wrote:Users of firmware 2.20 or older will have to rename nsa220_check_file.fw220_and_older to nsa220_check_file.
melhor wrote:I have a NSA-220 with Firmware Version 3.22 (AFB.0) <snip> renamed the file nsa220_check_file.fw220_and_older to nsa220_check_file . <snip> is there something i might did wrong?
;)

BTW, the fanctrld patch above should be applied on your system too. Let me know if it works.

melhor
Posts: 5
Joined: Tue Jan 12, 2010 10:38 am

Re: Debian Lenny on the NSA-220

Post by melhor » Tue Jan 12, 2010 12:49 pm

:lol: HAHA! Now i get it! older firmware means <2.20 and not >2.20. I must have mixed that up!

i'll give it another try.

cheers

melhor
Posts: 5
Joined: Tue Jan 12, 2010 10:38 am

Re: Debian Lenny on the NSA-220

Post by melhor » Tue Jan 12, 2010 1:39 pm

Mijzelf wrote:BTW, the fanctrld patch above should be applied on your system too. Let me know if it works.
There might be some problem with the unpacking parameters. when starting the script i get the error message:

Code: Select all

lzma: invalid option -- s
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors
EDIT: The correct option instead of -so should be -c for the standard output, then it worked!

cheers

Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Tue Jan 12, 2010 2:21 pm

Great! Can you remove the /usr/AllPack directory, and retry with a clean boot? And if that works, can you post the working /etc/init.d/nsa220.sh script?

This means that the 'Install to harddisk' instructions won't work either. initramfs mounts the firmware for it's /sbin/mdadm, which isn't available too.
I'll have to change it.

melhor
Posts: 5
Joined: Tue Jan 12, 2010 10:38 am

Re: Debian Lenny on the NSA-220

Post by melhor » Tue Jan 12, 2010 6:16 pm

No, the script doesn't work on startup, it doesn't even work if i call it manually. When calling the script with

Code: Select all

/etc/init.d/nsa220.sh start
nothing happens, no output and no action is taken. I even tried some outputs at the very beginning of the on_start() function ... nothing.
Is there any possibility to receive some debug output about whats happening right now?

Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Tue Jan 12, 2010 6:25 pm

sh -x /etc/init.d/nsa220.sh start

melhor
Posts: 5
Joined: Tue Jan 12, 2010 10:38 am

Re: Debian Lenny on the NSA-220

Post by melhor » Tue Jan 12, 2010 6:28 pm

okay, here comes the tricky part:
the script stops at the beginning at the line

Code: Select all

 [ -x "$DAEMON" ] || exit 0
because $DAEMON references to /sbin/fanctrld which is a symlink to /mnt/firmware/sbin/fanctrld ;)
uncommenting this line the script works perfect...

Mijzelf
Posts: 6197
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Tue Jan 12, 2010 6:56 pm

I'm innocent! I just customized the sample script! :mrgreen:

Great you sorted it. :D

sw4280
Posts: 1
Joined: Wed May 26, 2010 6:45 am

Re: Debian Lenny on the NSA-220

Post by sw4280 » Wed May 26, 2010 8:17 am

nice work!!

Is it possible to use debian lenny also on an zyxel nsa 210?

Post Reply