Install Debian Lenny on Stock Kurobox

This is a guide to installing the latest stable release of Debian Lenny 5.0.5 with 2.6.25.1 kernel on a KuroboxHG with stock firmware.

Introduction
Whilst much information is available for installing various Debian releases on the Kurobox/KuroboxHG, most installations require re-flashing the device's firmware with uBoot. This guide details installation on a Kurobox/KuroboxHG running the stock firmware, eliminating the risk of re-flashing with uBoot. This is achieved by installing Debian Sarge 3.1 as an auxiliary operating system, using loader.o to load a 2.6.25.1 kernel and then booting Debian Lenny 5.0.5 from a separate partition.

The Installation procedure is very simple and summarised by the following steps:


 * 1) Force EM Mode
 * 2) Login via Telnet
 * 3) Partition the Hard Drive
 * 4) Transfer Debian Images
 * 5) Extract Debian Images
 * 6) Configure and Reboot

Following this, Basic Configuration is discussed:


 * 1) Initial Configuration
 * 2) Optional Configuration
 * 3) Install Services

Finally, Limitations are outlined to encourage further development.

Force EM Mode
EM mode is easily entered by installing a new drive in your Kurobox.

Alternatively:

dd if=/dev/zero of=/dev/hda bs=512 count=1 reboot
 * SSH into KuroBox
 * Erase MBR:
 * Reboot:

OR

dd if=/dev/zero of=/dev/disk1 bs=512 count=1
 * Dismantle KuroBox by depressing tabs and sliding off sheath
 * Remove hard drive by further dismantling and removal of screws
 * Connect drive to another machine via IDE / USB->IDE converter
 * Erase MBR:
 * Reassemble KuroBox
 * Boot KuroBox

Log In via Telnet
Assuming you have successfully entered EM mode, the Kurobox will assume the address 192.168.11.150 in the absence of a DHCP server. If you are running DHCP, please consult your DHCP client list to determine the Kurobox's address.

Login via telnet: telnet 192.168.11.150
 * Username: root
 * Password: kuroadmin

Partition the Hard Drive
Our goal is to create the following partiton-table: /dev/hda1 Bootable Type 83(Linux) 2GB for Sarge /dev/hda2 Type 82(LinuxSwap) 256MB /dev/hda3 Type 83(Linux) 4GB for Lenny /dev/hda4 Type 83(Linux) the rest of the Disk

mfdisk -e /dev/hda mfdisk -c /dev/hda n p 1 +2048M a 1 n p 2  +256M t 2 82 n p 3 +4096M n p 4 p w  mkfs -j /dev/hda1 mkfs -j /dev/hda3 mkfs -j /dev/hda4 mkswap /dev/hda2 mkdir /mnt/hda1 mount /dev/hda1 /mnt/hda1 mkdir /mnt/hda3 mount /dev/hda3 /mnt/hda3
 * Clear existing partitions:
 * Create new partitions map (2GB Sarge[boot], 256MB Swap, 4GB Lenny, xxGB Data):
 * Create Sarge system partition:
 * Make Sarge system partition bootable:
 * Make Swap partition:
 * Designate Swap:
 * Create Lenny system partition:
 * Make Data:
 * Print partition map:
 * Write partition map to disk:
 * Format partitions:
 * Mount Sarge partition:
 * Mount Lenny partition:

Transfer Debian Images

 * Download the required images:
 * debian-sarge-2.6.25.1-kuroHG-20100722.tgz
 * debian-lenny-2.6.25.1-kuroHG-20100722.tgz


 * Connect to the KuroBox via FTP:
 * Address:    192.168.1.150
 * Username: root
 * Password:	kuroadmin


 * Transfer debian-sarge-2.6.25.1-kuroHG-20100722.tgz to /mnt/hda1


 * Transfer debian-lenny-2.6.25.1-kuroHG-20100722.tgz to /mnt/hda3

Extract Debian Images
cd /mnt/hda1 tar xvzf /mnt/hda1/debian-sarge-2.6.25.1-kuroHG-20100722.tgz
 * Extract Sarge image with:

cd /mnt/hda3 tar xvzf /mnt/hda3/debian-lenny-2.6.25.1-kuroHG-20100722.tgz
 * Extract Lenny image with:

rm /mnt/hda1/debian-sarge-2.6.25.1-kuroHG-20100722.tgz rm /mnt/hda3/debian-lenny-2.6.25.1-kuroHG-20100722.tgz
 * Delete the images with:

Note: If you are using a non-HG Kurobox, both Sarge and Lenny kernel images should be replaced by extracting http://www.genbako.com/kernelimage-2.6.25.1-kuroBOX.tgz to /mnt/hda1/boot' and /mnt/hda3/boot

Configure and Reboot
By default both debian installations are configured to acquire their address via DHCP with the hostname "KURO-BOX". If you need to change these details:

vi /mnt/hda1/etc/network/interfaces vi /mnt/hda3/etc/network/interfaces
 * Configure interfaces:
 * Sarge
 * Lenny

vi /mnt/hda1/etc/hostname vi /mnt/hda3/etc/hostname
 * Configure hostname:
 * Sarge
 * Lenny

vi /mnt/hda1/etc/resolv.conf vi /mnt/hda3/etc/resolv.conf
 * Configure DNS servers:
 * Sarge
 * Lenny

write_ok reboot
 * Finally, to boot into Debian Lenny 5.05, type:

Initial Configuration
After a successful reboot, the following initial configuration steps are recommended:


 * Log in via telnet
 * Username:	tmp-kun
 * Password:	tmp-kun

export TERM=vt100
 * Setup Terminal:

su
 * Switch to super user:
 * Password = root

passwd
 * Change root password:

adduser username
 * Create a user account:


 * Reconnect via Telnet as username

su
 * Switch to super user

deluser tmp-kun rm -Rf /home/tmp-kun/
 * Remove user tmp-kun:

apt-get update
 * Update Package List:

apt-get dist-upgrade
 * Upgrade installed packages:

Optional Configuration
By default the dual-boot installation will cycle between Sarge with stock kernel and Lenny with updated kernel after each reboot. Whilst this provides a safety net in the event that the Lenny installation fails to boot (i.e. reboot in Sarge, mount the Lenny filesystem and fix the problem), this behavior may be undesirable if you operate always-on services purely within Lenny.

To force the system to always boot Lenny with the updated kernel:

nano /etc/init.d/kernel_check.sh KERNEL=`uname -r` echo "Detected Kernel: $KERNEL" if [ $KERNEL = '2.4.17_mvl21' ]; then echo 'Rebooting...' /sbin/reboot fi +o, +x chmod +x /etc/init.d/kernel_check.sh crontab -e @reboot /bin/sh /etc/init.d/kernel_check.sh > /root/log.txt 2>&1 +o, +x
 * Boot into Sarge and login as root
 * Create a rebooter script:
 * Add the following content (replacing 2.4.17_mvl21 with your stock firmware revision [uname -r]):
 * 1) !/bin/sh
 * 2) Check Kernel Version
 * Save the script
 * Make the script executable:
 * Register an @reboot crontab process:

Now, whenever the system boots into Sarge it will detect the stock firmware and force a reboot into Lenny with the updated firmware. This behavior will allow you to reboot the server remotely with confidence that it will return running Lenny. It also simplifies the boot procedure to a single button push.

Note: There are definitely much more elegant ways of achieving this behavior, this only serves as a simple example.

Install Services
Services will vary dependant on usage, however most users will require SSH, installed via: apt-get install ssh

Limitations
Ideally the auxiliary Sarge installation should not be necessary, however much work is required to facilitate this. Please let me know if you have such a solution.

Please let me know or amend this article if you discover solutions or further limitations.

Change Log
28/09/2010

The shutdown and reboot limitations have now been resolved by means of a crontab @reboot script (detailed above). This script has not been incorporated into the repository images as it removes the built-in safety net that dual booting provides. (i.e. without the script if Lenny fails to boot you can reboot in Sarge, mount the Lenny filesystem and fix the problem; with the script if Lenny fails to boot you will need to force EM mode or remove the hard drive to rectify the problem).

23/07/2010

The Sarge image referenced here is derived from http://www.genbako.com/debian-2.6.17.3/debian-sarge-2.6.17.3-kuroHG-20060702.tgz, patched with the 2.6.25.1 KuroboxHG image found at http://www.genbako.com/kernelimage-2.6.25.1-kuroHG.tgz / http://www.genbako.com/modules-2.6.25.1-kuroHG.tgz. The sources.list has been updated to reflect the current 'archived' status of Debian sarge and all updates as of 23/07/2010 have been applied.

The Lenny image referenced here is derived from http://www.revulo.com/kuro-box/Debian/lenny.html, patched with the 2.6.25.1 KuroboxHG image found at http://www.genbako.com/kernelimage-2.6.25.1-kuroHG.tgz / http://www.genbako.com/modules-2.6.25.1-kuroHG.tgz. All updates as of 23/07/2010 have been applied.

Feedback
Feedback and discussion is welcomed via http://forum.buffalo.nas-central.org/viewtopic.php?f=41&t=22002