Plan of action
Installing Debian from scratch is a complex and lengthy process. This is our plan of action :
- Partition the drive
- Boot to a temporary debian system on /dev/hda3, so we can
- debootstrap debian, chroot to it, configure it and
- compile a vanilla mainstream kernel
- reboot and see if everything is all right
For this guide, you need to have the newer Uboot version, with the netconsole working, available in Kurobox support in stock 2.6 kernels. The guide also assumes you are using foonas-em.
Also, before proceeding, have your netconsole running, we'll need to enter special boot parameters. (Run "nc -u -p 6666 -v -v 192.168.0.100 6666", replacing 192.168.0.100 for your Kurobox Ip. Make sure your kurobox/desktop are ready to use the netconsole)
(Re)Partitioning the drive
Get on EM mode
Get on EM mode. On foonas-em this is done by pressing the Power button one time after the device powered on, and while the power light is still slowly blinking. If you can't get on EM mode by this way, you can enter 'run fooflboot' on the netconsole.
Partition the disk
We will create 3 partitions : one with about 3GB for the Debian system, another one with 256MB for swap, and another one that takes the rest of the disk.
# fdisk /dev/sda -> o ( enter ) (clean the partition table on the disk) -> n, p, 1, (enter), +3000M; (New Primary partition in position 1, from start to 2048M after it) -> a, 1; (Set partition 1 as bootable) -> n, p, 2, (enter), +256M; (New Primary partition in position 2, from the first free spot to 256M after it) -> t, 2, 82; (set Type of partition 2 as 82 (Linux Swap) -> n, p, 3, (enter), (enter); (New Primary partition 3, taking the rest of the disk) -> w (write the changes to the disk - THIS WILL REFORMAT YOUR HD! BACKUP YOUR DATA! - ) # mkfs.ext3 -j /dev/sda1 (Create a new journaled ext3 filesystem on /dev/sda1) # mkfs.ext3 -j /dev/sda3 (Create a new journaled ext3 filesystem on /dev/sda1) # mkswap /dev/sda2 (Create a swap filesystem on /dev/sda2)
Install a temporary Debian system on /dev/hda3
If you already have a working installation of a 2.6 Linux system, you can skip this part and debootstrap from there directly. See Debootstrap Ubuntu from Gentoo
Now we will prepare to boot a pre-made image on /dev/hda3, so we can use the debootstrap tool later on to create our final system on /dev/hda1. Make sure you grab a kernel version compatible with your box.
Have the Debian image ready for boot
# mount /dev/hda3 /mnt # cd /mnt # wget http://www.nicholassavilerobinson.com/repository/debian-sarge-184.108.40.206-kuroHG-20100722.tgz # tar xvzf debian-image.tgz # cd boot/ # wget http://www.genbako.com/uImage/kernelimage-xxxxxxx-uImage.tgz # tar xvzf linux-kenel_image.tgz # vi etc/fstab (make sure everything is ok - /dev/hda3 should mount on /, hda1 should mount on /mnt) # reboot
At this point, have your netconsole running on your pc, be ready to stop the boot procedure hitting 's'.
Running debootstrap on the Debian Image
These steps are done on the netconsole :
-> Hit 's' before the timeout comes => ext2load ide 0:3 800000 boot/vmlinux.UBoot (load the kernel on the memory) => setenv bootargs root=/dev/hda3 (set that the root file system is on hda3) => bootm 800000 (finally, boot from that memory address)
Hopefully the Debian image will boot. Back on the normal shell, telnet to it :
# telnet 192.168.0.100 (username and password : tmp-kun ) # su (root password : root ) # apt-get update
Get the url of the lastest deboostrap .ded package for debian :
# wget http://ftp.br.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.28_all.deb # dpkg -i debootstrap_1.0.28_all.deb # debootstrap --arch powerpc squeeze /mnt http://ftp.br.debian.org/debian/
This will setup a base system on /mnt, and it will take a while. Nice time for a coffee :)
Configuring your Debian system
At this point, we will get the system ready to be booted on.
# cp /etc/fstab /mnt/etc/fstab (just a template that will help us configuring fstab later) # chroot /mnt /bin/bash # mount -t proc proc /proc
Note that we will use the mainstream kernel on this system. This means that we have to use the PATA drivers, instead of IDE. So edit your fstab file, make sure sda1 goes to /, and sda3 goes to /mnt. Ensure we have no "hda1", "hda2" or "hda3", replace for "sda1", "sda2", "sda3".
# vim /etc/fstab
We have to ensure the box will connect to the network. So edit the /etc/network/interfaces file.
# vim /etc/network/interfaces (configure to use with dhcp or static config)
If you use DHPC :
auto eth0 lo iface eth0 inet dhcp iface lo inet loopback
If you use a static setting (replace the ips to fit you) :
auto eth0 lo iface eth0 inet static address 192.168.0.100 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 iface lo inet loopback
Ok, let's move on :
# vim /etc/resolv.conf (make sure that is has your nameserver/router) # echo NameOfYourBox > /etc/hostname (this is the coolest part - name your host! ) # vim /etc/hosts (Update your hosts file with your new IP & hostname (if using static IP) 127.0.0.1 localhost 192.168.1.100 NameOfYourBox # vim /etc/apt/sources.list ( you can generate one for you on http://debgen.simplylinux.ch/ ) # apt-get update # apt-get install console-data (reconfigure keyboard, if needed) # vim etc/hosts.allow (you should add your network there) ALL : 192.168.0.0/255.255.0.0 ALL : 127.0.0.1 # dpkg-reconfigure tzdata (adjust your timezone) # adduser YourUserName # passwd (change the root password) # apt-get install sudo # vim /etc/sudoers (add the following to the file, and save, so your user can use sudo) YourUserName ALL=(ALL) NOPASSWD: ALL # apt-get install ssh (you'll need this to login to your Kurobox later)
Building the kernel
# apt-get install git git-core make patch unzip bison flex libncurses5-dev gcc (install the additional packages for compiling kernel) # chown -R YourUserName:users /usr/src (you need permission to write on that folder) # su YourUserName (this part is meant to be run as a normal use) $ cd /usr/src $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.bz2 (get the most recent from http://www.kernel.org/pub/linux/kernel) $ tar xjf linux-2.6.37.tar.bz2 $ ln -sf linux-2.6.37 linux $ git clone git://www.jdl.com/software/dtc.git dtc (the dtc tool is used to compile a required special hardware database file) $ cd /usr/src/dtc $ make $ sudo ln -sf /usr/src/dtc/dtc /usr/local/bin/ $ sudo apt-get install uboot-mkimage (that is needed to produce kernel images that the u-boot can boot into) $ cd /usr/src/linux $ cp arch/powerpc/configs/linkstation_defconfig .config $ make menuconfig $ make uImage modules $ exit # cd /usr/src/linux # make modules_install # cp arch/powerpc/boot/uImage /boot/vmlinux.UBoot # cp arch/powerpc/boot/dts/kuroboxHG.dts /boot/ # cd /boot # dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts # reboot
Boot your Ubuntu OS
$ sudo apt-get install avr-evtd $ sudo vim /etc/default/avr_evtd (tweak the configuration to suit your needs)
Make Hwclock work
Hwclock only reads from /dev/rtc, but the system makes /dev/rtc0. Add this command to have udev to link rtc->rtc0 every time the system boots, so you can use the hwclock command. Just add the line to the file:
$ sudo vim /etc/udev/rules.d/50-udev.rules KERNEL=="rtc0", SYMLINK+="rtc"
If you see the following error when running perl:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_GB.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").
# locale-gen en_GB.UTF-8 en_US.UTF-8
(be sure to choose an appropriate locale)
Inform the repository that you are using the packages related to the Kurobox, so they don't get forgotten, run :
# sudo apt-get install popularity-contest
How could this guide be improved
- A better foonas-em busybox, comming with ar, that would allow debootstrapping directly without the need to boot the temporary debian image.