Wednesday, December 9, 2009

Linux on Windows: Part-2 (Colinux)

 

clip_image002

Cooperative Linux is the first working free and open source method for optimally running Linux on Microsoft Windows natively. More generally, Cooperative Linux (short-named coLinux) is a port of the Linux kernel that allows it to run cooperatively alongside another operating system on a single machine. For instance, it allows one to freely run Linux on Windows 2000/XP/Vista/7, without using commercial PC virtualization software such as VMware, in a way which is much more optimal than using any general purpose PC virtualization software. In its current condition, it allows us to run the KNOPPIX Japanese Edition on Windows.

Step by Step Guide to install and configure Colinux on your PC:

In this post i will be explaining how to download, install and configure CoLinux with Debian 4.0 file system image. It can be seen as an alternative to a conventional "dual boot" configuration - but with both systems running at the same time.

NOTE: This is a really long post, continue only if you can spare some time on it. smile_wink

Download and installation

You can download the latest version of CoLinux binary from the following link:

http://sourceforge.net/projects/colinux/files/coLinux-stable/

I will be using the stable version 0.7.3 (kernel 2.6.22.18).

Here you can find some file system images, go for the image which u feel comfortable with:

http://sourceforge.net/projects/colinux/files/

Screenshots of installation steps:

 

clip_image004

clip_image006

During the installation the WinPcap (The Windows Packet Capture Library) is installed.

clip_image008

We can download (some of) available filesystem images directly during the installation:

clip_image010

TAP network adapter is installed (If any hardware installation error comes, click on “continue anyway”;-)

clip_image012

Now the TAP adapter is installed (but not connected):

clip_image014

We have to configure the private IP address of the host system (windows):

clip_image016

Installation paths:

CoLinux binary: c:\programs\coLinux

Filesystem images: c:\programs\coLinux\images

Configure (Windows side:

Config file :

We create a new configuration file (just modify the installed example.conf):

C:\> cd programs\coLinux

C:\programs\coLinux> copy example.conf debian.conf

1 file(s) copied.

C:\programs\coLinux> notepad debian.conf

Now we can specify root image, swap file and possibly other mount points and also define two ethernet devices - one for pcap bridge and second for TAP adapter:

...

# File contains the root file system.

# Download and extract preconfigured file from SF "Images for 2.6".

cobd0="C:\programs\coLinux\images\Debian-4.0r0-etch.ext3.1gb"

cofs1=c:\

cofs2=d:\

# Swap device, should be an empty file with 128..512MB.

cobd1="C:\programs\coLinux\images\swap_file.1gb"

# Tell kernel the name of root device (mostly /dev/cobd0,

# /dev/cobd/0 on Gentoo)

# This parameter will be forward to Linux kernel.

root=/dev/cobd0

# Additional kernel parameters (ro = rootfs mount read only)

ro

# Initrd installs modules into the root file system.

# Need only on first boot.

initrd=initrd.gz

# Maximal memory for linux guest

#mem=64

# Slirp for internet connection (outgoing)

# Inside running coLinux configure eth0 with this static settings:

# ipaddress 10.0.2.15 broadcast 10.0.2.255 netmask 255.255.255.0

# gateway 10.0.2.2 nameserver 10.0.2.3

#eth0=slirp

# pcap bridge for internet connection (outgoing)

eth0=pcap-bridge,"Local Area Connection",<an-artificial-mac-address>

# Tuntap as private network between guest and host on second linux device

eth1=tuntap

# Setup for serial device

#ttys0=COM1,"BAUD=115200 PARITY=n DATA=8 STOP=1 dtr=on rts=on"

# Run an application on colinux start (Sample Xming, a Xserver)

# exec0=C:\Programs\Xming\Xming.exe,":0 -clipboard -multiwindow -ac"

Swap file :

Also you have to create a swap file, http://colinux.wikia.com/wiki/HowtoCreateSwapFile is how to create it, or if you are lazy like me, you can download one from http://gniarf.nerim.net/colinux/swap/

Configure (Linux side):

Start colinux daemon:

C:\programs\coLinux> colinux-daemon.exe @debian.conf

Cooperative Linux Daemon, 0.7.3

Daemon compiled on Sat May 24 22:36:07 2008

PID: 3268

error 0x2 in execution

error launching console

daemon: exit code 8200c401

daemon: error - CO_RC_ERROR_ERROR, line 49, file src/colinux/os/winnt/user/exec.c (16)

We did not install the generic console so we have to explicitly say we want to launch the NT console:

C:\programs\coLinux> colinux-daemon.exe -t nt @debian.conf

Login as root (a default password is "root"):

login as: root

root@10.0.2.2's password:

Linux debian 2.6.22.18-co-0.7.3 #1 PREEMPT Sat May 24 22:27:30 UTC 2008 i686

The programs included with the Debian GNU/Linux system are free software;

the exact distribution terms for each program are described in the

individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent

permitted by applicable law.

Change the root password

deb# passwd

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

Network

For easy to use the network is pre-configured for "slirp":

deb# ifconfig

eth0 Link encap:Ethernet HWaddr 22:01:76:23:42:12

inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:59 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:20682 (20.1 KiB) TX bytes:0 (0.0 b)

Interrupt:2

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

We change it to dual-ethernet mode (one for outside world connection and other for private network between guest and host system):

deb# nano /etc/network/interfaces

Comment out the following:

# The primary network interface (slirp)

auto eth0

iface eth0 inet static

address 10.0.2.15

broadcast 10.0.2.255

netmask 255.255.255.0

gateway 10.0.2.2

And replace it with following:

# The primary network interface

auto eth0

iface eth0 inet dhcp

Then there is the following:

# Second network (tap-win32)

#auto eth1

#iface eth1 inet static

# address 192.168.0.40

# netmask 255.255.255.0

... leave it as is (or remove it) and add the following:

auto eth1

iface eth1 inet static

address 10.0.2.2

network 10.0.2.0

netmask 255.255.255.0

broadcast 10.0.2.255

Now save the file and reboot:

deb# reboot

We should see now on the Windows side that the TAP adapter is connected:

clip_image018

After we login to linux, we can examine the new network configuration:

deb# ifconfig

eth0 Link encap:Ethernet HWaddr <an-artificial-mac-address>

inet addr:192.168.1.196 Bcast:192.168.1.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:17220 errors:0 dropped:0 overruns:0 frame:0

TX packets:11031 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:24760203 (23.6 MiB) TX bytes:770417 (752.3 KiB)

Interrupt:2

eth1 Link encap:Ethernet HWaddr 00:FF:68:B7:70:00

inet addr:10.0.2.2 Bcast:10.0.2.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:17 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:2238 (2.1 KiB) TX bytes:0 (0.0 b)

Interrupt:2

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Packaging system

Now (we are connected to the internet) it is time to update the package system and upgrade installed packages:

deb# apt-get update

...

deb# apt-get upgrade

The following packages will be upgraded:

bsdutils cpio debconf debconf-i18n debian-archive-keyring dpkg e2fslibs

e2fsprogs findutils initscripts libblkid1 libc6 libcomerr2 libgnutls13

libpam-modules libpam-runtime libpam0g libss2 libuuid1 lsb-base mount nano

perl-base sysv-rc sysvinit sysvinit-utils tar tzdata util-linux

29 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Need to get 12.3MB of archives.

After unpacking 1786kB disk space will be freed.

Do you want to continue [Y/n]? Y

...

Mount table

Now we can modify the mount table:

deb# nano /etc/fstab

... add the following if you want to mount C: and D: windows drives (we made it available as cofs devices in debian.conf file):

cofs1 /mnt/c cofs defaults,noatime 0 0

cofs2 /mnt/d cofs defaults,noatime 0 0

Now the command:

deb# mount –a

... works as expected.

 

Now go and try it yourself  smile_nerd

 
Things You Should Know About Linux !!!