Thursday, January 20, 2005

KNOPPIX + CoLinux howto

Following a long battle to get some kind of modern linux system
installed on my work pc, i succeeded in installing CoLinux with KNOPPIX
rootfs.

This is a short description of steps involved which can be treated as
a crude HOWTO

Software to be downloaded

1.Colinux latest release from colinux.org.
2.KNOPPIIX ISO image or a CD.
3.QEMU for windows,you can get it at freeoszoo.org. (needed if you don't have a CD and don't want to burn one then you will also need or for some reason can't boot from the cd.)
4. Cygwin + X (or any other x server for windows)

You will also need atleast 2000 MB of harddisk space on windows
partion _and_ atleast 512 MB more for swap image.

Also please read the documentation available on coLinux site before you begin.
TODO : add links

STEP 1: prepare KNOPPIX rootfs image.

The single large problem with running knoppix with colinux is that
colinux kernel does not contain the cloop modules. cloop is the
module used by KNOPPIX to compress its root file system. This makes it
impossible to mount the KNOPPIX fs directly under coLinux.

So you will need to get the rootfs decompressed first before you can
use it under coLinux.

There are two ways of doing this.
1. If you have the cd and can boot into it.
a. Just boot into knoppix and be root.
b. Mount a windows drive
c. use dd to copy /dev/cloop0 to to knoppix_rootfs.img on you disk

dd if=/dev/cloop0 of=knoppix_rootfs.img

the img will be about 2000MB so be sure you have enough space.

d.Once the copying is done you will have to loopmount the image.

mkdir /mnt/rootfs
mount -o loop knoppix_rootfs.img /mnt/rootfs

e. go to /mnt/rootfs/dev directoy and add follwing devices

mknod /mnt/rootfs/dev/cobd0 b 117 0
mknod /mnt/rootfs/dev/cobd1 b 117 1
mknod /mnt/rootfs/dev/cobd2 b 117 2

f. go to /mnt/rootfs/etc and edit fstab to add following entries
/dev/cobd0 / auto defaults 0 0
/dev/cobd1 none swap defaults 0 0

remove any other entries for '/' and swap

g. unmount /mnt/rootfs

2. If you don't have the cd or you can't boot into it
a. Get the ISO or rip the cd into an ISO
b. install QEMU from freeoszoo.org
c. Configure QEMU to mount the knoppix iso as cdrom (instructions can
be found at freeos zoo.org)
d. Create an empty file of 2000MBs, you might use something else from
windows world, i used cygwin dd to do that

dd if=/dev/null of=knoppix_rootfs.img count=4000 bs=512

e. Configure QEMU to mount the empty rootfs as hda.
f. Fire up qemu this should boot into knoppix cd.
g. Boot knoppix 3 to go directly to commandline.
h. once booted make sure you are root and the copy /dev/cloop0 to /dev/hda

dd if=/dev/cloop0 of=/dev/hda

i. Once the copying is done mount /dev/hda onto /mnt/hda
j. go to /mnt/hda/dev and create following nodes

mknod /mnt/hda/dev/cobd0 b 117 0
mknod /mnt/hda/dev/cobd1 b 117 1
mknod /mnt/hda/dev/cobd2 b 117 2

k. go to /mnt/hda/etc and edit fstab to add following entries
/dev/cobd0 / auto defaults 0 0
/dev/cobd1 none swap defaults 0 0

remove any other entries for '/' and swap

l. unmount /mnt/hda

Thats it, this will get you to boot knoppix over colinux.

Running Colinux
1.Install Colinux using the setup programm.
2.Make sure you have the N/W driver installed.
3. Install some kind of X server, best one to use is cygwin X
4. Change your configuration file to point to the rootfs we created
5. create a 512 MB file to be used as swap.
6. Change your configuration file to point to the swap we created
Important part is to match the cobd numbers to the ones we entered in /etc
Also make sure you passing

My config looks like this,
<?xml version="1.0" encoding="UTF-8"?>
<colinux>
<!-- This line needs to point to your root file system.
For example change "root_fs" to the name of the Debian image.
Inside coLinux it will be /dev/cobd0 -->
<block_device index="0" path="\DosDevices\d:\scratch.img"
enabled="true" />

<!-- This line can specify a swap file if you wish, or an additional
image file, it will /dev/cobd1. Additional block_devices can
be specified in the same manner by increasing the index -->

<block_device index="1" path="\DosDevices\c:\swap_device"
enabled="true" />

<!-- bootparams allows you to pass kernel boot parameters -->
<bootparams>root=/dev/cobd0 lang=en 3</bootparams>

<!-- image allows you to specify the kernel to boot -->
<image path="vmlinux" />

<!-- this line allows you to specify the amount of memory available
to coLinux -->
<memory size="64" />

<!-- This allows you to modify networking parameters, see the README
or website for more information -->
<network index="0" type="tap" />
</colinux>


Thats it done fireup Colinux
This should boot into knoppix root shell
There is one glitch here, the hwsetup will screwup and lots of errors
will be output for not finding modules, ignore them for a while
The hwsetup will keep outputing gree blocks on console,
type
killall -KILL hwsetup
And you will have stable prompt.
Not first thing to do is edit /etc/fstab and remove some errornous
things appended and restore it to point to right '/' and swap devices
i.e. /dev/cobd0 /dev/cobd1 in our case
Rest of the things will be setup correctly,
Give
ifconfig eth0 192.168.0.197 up
to start communicating with X server
set DISPLAY and then give startkde you should have a kde session started on your
windows x server.

export DISPLAY=192.168.0.1:0 (assuming the address given to windows pc is .1)
startkde

Problems:
The knoppix is not properly installed on the system but is just
copied, this leaves lots of settings undone, most annoyingly the
permissions are set only for root and knoppix user. If you try to use
a normal user you will have to constantly fiddle with permissions to
get things working.
The solution is to install the knoppix to the disk image instead of
copying it. But in my case the knoppix installer won't install to an
image file for unkown reasons.

4 comments:

Darth Chatri said...

Looks like you have been having some fun lately :)
Why not just take the debian image, get the Sarge CDs and do an apt-cdrom add, apt-get update, apt-get dist-upgrade?

BAIN said...

I think i should mention the specific problems i was facing.

I can't burn cds,
I can't bring external cds inside the building without authorisation (its not my comp. i am on site) (funny cause i could always download them :-D )
I have limited disk space 3 GB max for my personal use.
Network is not that fast.( I could download knoppix cd overnight though )
KNOPPIX is preconfigured sarge isn't as optimised as knoppix.

The last part was most prominant in using knoppix, i tried the update thing but it was just too slow for me due to network + the fact that this was PIII 450 m/c i am using :-))

Mostly getting any linux system to run was a big challange.

Anonymous said...

Hi,

I thought the whole idea of Colinux was to be able to run a complete Linux dist on Windows - including the GUI without having to run a Windows Xserver?
I am about to give your howto a try now. I have tried the Gentoo Image on sourceforge and had all sorts of problems with it - including the fact that the system keeps saying the partitions under the running Gentoo is read-only.
Thanks a lot for the howto - I have always wondered what makes a Linux "image" of this sort :-)

Anonymous said...

Can't run mknod on /mnt/hda/dev as it is an iso9660 file system, and hence "read only". :-(