Overview

I have a Kurobox HG, that has been running Gentoo for a while now. After getting fed up with the waits for compiling packages I decided to switch over to Debian.

Only having SSH access to the box makes switching OS a slightly more tricky prospect than a standard OS switch or upgrade.

The basic plan is:

  1. Disable swap
  2. Install a very basic debian system onto the swap partition
  3. Reboot into the basic debian system
  4. From the basic debian system, install a debian system onto the main partition
  5. Reboot into the basic debian system on the main partition
  6. Reformat and enable the swap partition
  7. Finish configuring the new system

There were a few tricky steps along the way, so I've documented all the steps below.

Notes

The following disk layout is being used:

 / on /dev/sda1
 swap on /dev/sda2
 /var on /dev/sda3
 /media on /dev/sda4

debootstrap

Debian provides a tool called debootstrap for setting up a basic debian system. Very useful in situations like this or for setting up chroot environments for package building and cross compiling.

Download and install the latest debootstrap:

 # tar xvzf debootstrap_1.0.20.tar.gz
 # cd debootstrap_1.0.20
 # make
 # make install

Once this is built, we can create our basic Debian system in our swap space.

 # swapoff /dev/sda2
 # mkfs.et3 /dev/sda2
 # mkdir /mnt/debian
 # mount /dev/sda2 /mnt/debian

Minimal Debian system

 # debootstrap --arch powerpc lenny /mnt/debian http://ftp.debian.org/debian/

Grab a cup of tea!

 # cp /etc/fstab /mnt/debian/etc
 # chroot /mnt/debian
 # mount -t proc proc /proc
 # apt-get install openssh-server
 # passwd root
 # apt-get install udev

Edit fstab to use /dev/sda2 as /

 # vi /etc/fstab

Setup /etc/network/interfaces to static:

 auto eth0 lo
 iface eth0 inet static 
 address 192.168.1.40
 network 192.168.1.0
 netmask 255.255.255.0 
 broadcast 192.168.1.255 
 gateway 192.168.1.254 
 iface lo inet loopback

Done in the chroot for now, so:

 # exit

We can simply reuse the existing kernel from the current Gentoo system:

 # cp -a /boot/* /mnt/debian/boot
 # cp -ar /lib/modules/* /mnt/debian/lib/modules

Backup a few files for future reference as we will be shortly wiping the current system. I backed up mysql and all of /etc for future reference.

Rebooting into the minimal Debian system

I used the following commands at the U-Boot console to boot into the Debian system on the old swap partition. IP addresses would have to be changed to suit.

 setenv hdpart 0:2
 echo Loading ${hdpart}:${hdfile};ext2load ide ${hdpart} ${ldaddr} ${hdfile};ext2load ide ${hdpart} 7f0000 boot/kuroboxHG.dtb
 setenv bootargs root=/dev/sda2 netconsole=6666@192.168.1.40/,@192.168.1.3/ rtc-rs5c372.probe=0,0x32;bootm ${ldaddr} - 7f0000

Hopefully, fingers crossed you should now be running the new minimal Debian system.

Installing the new system

You can now use debootstrap again to install what will become the new full system.

The first time around I formatted my partitions like so:

 # mkfs.ext3 /dev/sda1
 # mkfs.ext3 /dev/sda3

Upon first attempting to boot into the new full Debian system, it failed. U-Boot was complaining about not being able to find the kernel despite it very definitely being in the correct place. After booting up into EM mode and attempting to mount /dev/hda1 and seeing a message about an unsupported inode size of 256, I figured this may be the cause. Turns out U-Boot (at least the version I have installed), can't handle inode sizes above 128. So I had to start this step from scratch passing in the inode size to mkfs, like so:

 # mkfs.ext3 -I 128 /dev/sda1
 # mkfs.ext3 -I 128 /dev/sda3

Create the chroot directories and mount them:

 # mkdir /mnt/debian
 # mount /dev/sda1 /mnt/debian
 # mkdir /mnt/debian/var
 # mount /dev/sda3 /mnt/debian/var

Create the basic debian system using debootstrap again

 # debootstrap --arch powerpc lenny /mnt/debian http://ftp.debian.org/debian/
 # cp /etc/fstab /mnt/debian/etc
 # chroot /mnt/debian
 # mount -t proc proc /proc
 # apt-get install openssh-server
 # passwd root

Change fstab back to be like original one referencing /dev/sda1 and /dev/sda3, swap space is still disabled as
that is where we are currently running debian from.

Setup /etc/network/interfaces to static:

 auto eth0 lo
 iface eth0 inet static 
 address 192.168.1.40
 network 192.168.1.0
 netmask 255.255.255.0 
 broadcast 192.168.1.255 
 gateway 192.168.1.254 
 iface lo inet loopback

Exit from the chroot so we can get the kernel copied over:

 # exit

Copy over kernel and modules

 # cp -ar /boot/* /mnt/debian/boot
 # cp -ar /lib/modules/* /mnt/debian/lib/modules

Back into the chroot to sort out a few more bits:

 # chroot /mnt/debian
 # echo kuro > /etc/hostname
 # vim /etc/hosts.allow

Generate repository list using the excellent site at debgen.simplylinux.ch and copy the results into /etc/apt/sources.list

 # apt-get update
 # apt-get install console-data
 # dpkg-reconfigure console-data
 # apt-get install locales
 # dpkg-reconfigure locales
 # apt-get install udev
 # dpkg-reconfigure tzdata

Reboot into new Debian and hope all goes well!

Post reboot cleanup

Only one more thing todo, re-create and re-enable our swap space:

 # mkswap /dev/sda2
 # swapon /dev/sda2

Now you have a basic Debian system up and running, all installed via SSH! Install some apps and get on without waiting for things to compile.

Notes

To get ssh -Y working I had to do a couple of things:

  1. apt-get install xbase-clients
  2. Add 'X11UseLocalhost no' to /etc/ssh/sshd_config

2 thoughts on “Installing Debian via SSH

    • Sorry for the slow reply. Due to performing the OS switch without being able to alter the UBoot environment much.

      It's a fairly niche requirement and likely not necessary with current hardware/software I imagine. My memory was that UBoot was a bit tricky to work with, hence the two step install to get a full install of Debian up and running.

      Reply

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required