You are on page 1of 7

Virtualization with coLinux http://www.ibm.

com/developerworks/linux/library/l-virtualization-colinux/

Virtualization with coLinux


Using, installing, and configuring Cooperative Linux

Level: Introductory

M. Tim Jones (mtj@mtjones.com), Consultant Engineer, Emulex

31 Mar 2007

Virtualization with VmWare, Xen, and Kernel-based Virtual Machine (KVM) are all the rage these days. But did
you know that you can run Linux® cooperatively with Microsoft® Windows®? This article explores
Cooperative Linux (coLinux), starting with a quick introduction to virtualization and then looking at the approach
taken by coLinux. You'll also see how to get coLinux up and running on Windows.

Cooperation is probably the last thing you think of when considering GNU/Linux and Microsoft Windows, but that's exactly
what you get with the coLinux kernel. Not convinced? Skip ahead to "Advantages of coLinux."

coLinux is a port of the Linux operating system that executes as a single process in the Microsoft operating system. The
operating systems cooperate with each other by giving each other the central processing unit (CPU), as shown in Figure 1.

Figure 1. Microsoft Windows and Linux cooperate with each other in coLinux

Through the use of kernel drivers, physical resources such as the networking interface are also shared. More on this later. First,
what is meant by virtualization?

Virtualization
Virtualization is an over-used term. In the context of this article, I'm The spectrum of virtualization
referring to the platform variation. Virtualizing a platform (or hardware) This article focuses on a cooperative solution
means that the hardware is abstracted from a physical platform into a to platform virtualization, but the term applies
collection of logical platforms onto which operating systems can be run. In to other techniques as well. For example:
the simplest sense, this means that you can run multiple operating systems In storage, you can virtualize many
(of the same or different types) on the same hardware platform. disks to look like a pool of storage that
can be allocated based on need.
The element of the system that provides the virtualization is commonly
You can also virtualize networks,
known as a virtual machine monitor or hypervisor. Each operating system
though this is usually called zoning.
uses its own virtual machine that cooperates with the hypervisor to arbitrate
OS virtualization, which is a simpler
access to the physical hardware (see Figure 2).
form of virtualization, virtualizes
servers running on an operating system.
Figure 2. The hypervisor arbitrates access to the physical hardware

Like operating systems, the methods available for virtualization are wide and varied. For more information about virtualization,
see the Resources section.

1 of 7 9/23/2008 1:47 PM
Virtualization with coLinux http://www.ibm.com/developerworks/linux/library/l-virtualization-colinux/

coLinux
coLinux is a port of the standard Linux kernel. In other words, coLinux is the Linux kernel that's modified to run cooperatively
with another operating system. The host operating system (Windows or Linux) maintains control of the physical resources of
the operating system, while the guest operating system (coLinux) is provided with a virtual abstraction of the hardware. The
host operating system must provide the means to execute a driver in the privileged ring (ring 0) and export the means to
allocate memory (see Figure 3).

Figure 3. coLinux executes as a process of the host operating system

The root file system for coLinux is a regular file within the host operating system. To Windows it's just a regular file, but to
coLinux it's an ext3 file system that can be read and written to.

Other features needed by the Linux kernel, such as networking or video access, are proxied externally. Networking is made
accessible to coLinux through a TUN/TAP driver (which is covered in "Networking," below). In short, this driver provides
user-space access to the Ethernet device so that packets can be transmitted and received. Access to the display is also
proxied. Recall that X Window System is a protocol by which video output can be sent from one host to another. Therefore, by
using an X Window System server on the host operating system, video output can be redirected to the available X server.

Now on to the installation of coLinux and configuration for both networking and video display.

Installing coLinux
Installing coLinux is surprisingly simple. There are a few steps involved, depending upon what you intend to do, but they're
straightforward and worked on my Windows XP box without a single problem. This section explores installing coLinux and
enabling services such as networking.

The first step is to download a coLinux distribution. Go to http://www.colinux.org and select Downloads from the
left sidebar. If your browser doesn't take you to SourceForge, select the link to go there directly. Near the middle of the page
is the coLinux-stable package. Download the coLinux executable file (at the time of this writing, the latest is coLinux-
0.6.4.exe). The 0.6.4 release of coLinux is the 2.6.11 Linux kernel. When it has finished downloading, double-click the file to
install.

After the usual license acceptance, you'll be asked for the components that you'd like to install. Leave these as is (all should
be selected), including downloading a root file system image. To make things easier later on, change the destination folder for
the coLinux install to c:\colinux\ because colinux is the standard install subdirectory from the perspective of configuration
files.

When the installation program asks for a root file system image, select the Debian distribution because it's the smallest and
extracts to only 1GB. Select Install to perform the install and root file system download.

When the install completes, you're not quite done yet. The next step is to open a folder to the install subdirectory to
decompress the root file system.

The coLinux README file includes lots of additional information about other install options. This is available in the install
subdirectory (c:\colinux). There will be an oddly named file that ends in .bz2. Rename this file to root_fs (this is the default
root file system file in the configuration).

At this point, installation of coLinux is basically done. You can then start the coLinux daemon to run with Windows XP as
follows (invoking through a Command Prompt window):
$ colinux-daemon.exe -c default.colinux.xml

2 of 7 9/23/2008 1:47 PM
Virtualization with coLinux http://www.ibm.com/developerworks/linux/library/l-virtualization-colinux/

After invoking the colinux-daemon, the boot window is displayed (see Figure 4). This provides the same boot information
that you find in the traditional Linux boot. Notice that coLinux boots extremely fast.

Figure 4. The coLinux boot window

A console window is also produced (see Figure 5) that attaches to the colinux-daemon. From this window, you can log in
to coLinux to interact with the shell. The default username and password is root/root.

Figure 5. The coLinux virtual console (shell)

From Figure 5, you can see that the coLinux console is made up of two sections: the traditional console and the virtual console
that provides information about the monitor.

Networking
Networking support for coLinux is done from the Linux perspective when the install is complete. Recall that the TAP driver is
loaded during the install. The TAP driver is a user-space tap onto the Ethernet device managed by the host operating system.
The TAP driver allows the guest operating system to read or write raw Ethernet frames to a virtual Ethernet device (extended
to user space). The virtual Ethernet device in user space then moves Ethernet frames to and from the real Ethernet device in
the host operating system. Note that the TAP driver moves Ethernet frames, while the TUN driver is used for Internet Protocol
(IP) frames.

3 of 7 9/23/2008 1:47 PM
Virtualization with coLinux http://www.ibm.com/developerworks/linux/library/l-virtualization-colinux/

For the TAP driver to work, the host operating system must share the available Ethernet device. To enable sharing within
Windows XP, open the Network Connections panel from the Control Panel. Select the active local area connection, and then
open the properties. Select the Advanced tab, and then select the check box for allowing other network users to connect
through this computer's Internet connection (see Figure 6).

Figure 6. Local area connection properties for enabling network device sharing

After the network is shared, you can start coLinux and use the network as you would normally. This is shown in Figure 7 with
the ping command.

Figure 7. Using the shared network device is transparent with coLinux through the TAP driver

With little effort and configuration, coLinux provides networking out of the box. For more information about networking with

4 of 7 9/23/2008 1:47 PM
Virtualization with coLinux http://www.ibm.com/developerworks/linux/library/l-virtualization-colinux/

TUN/TAP, check out the Resources section.

X Window System
A console window is fine, but a graphical window manager would be ideal. With an open source X server, such as Xming, you
can create xterms or use other graphical applications with coLinux. There are numerous documented options, such as Virtual
Network Computing (VNC), but I'll show you how using Xming.

The first step is to download Xming from SourceForge. After installing, there's one file, called X0.hosts, that you need to
update in the install subdirectory. It contains the remote hosts that are permitted access to the X server. Simply add the IP
address of the machine that hosts the coLinux process. Start the Xming X server and coLinux, and then perform the following
commands in coLinux:
colinux:~# export DISPLAY=192.168.1.3:0.0
colinux:~# xterm &

Note that the IP address specified here is the IP address of the coLinux host. After you execute the xterm command, a new
xterm window is presented, as shown in Figure 8.

Figure 8. The xterm created with Xming

Extending coLinux
Whichever root file system you download, it may not include everything that you'd like. But you can easily extend the root file
system. For example, with Debian GNU/Linux, you can use the Advanced Packaging Tool (APT), a package management
system, to install new packages or update existing ones. The first step is to update the APT metadata, which maintains
management information about the installed packages (including newly available packages and where to get them):
$ apt-get update

Now you can update your root file system with other packages that you need. For example, if you want to add the wonderful
Ruby language to your root file system, you invoke the following command:
$ apt-get install ruby

In this way, you can use an existing root file system and tailor it to your specific needs. You can also rebuild coLinux from the
sources if it lacks something that you need.

5 of 7 9/23/2008 1:47 PM
Virtualization with coLinux http://www.ibm.com/developerworks/linux/library/l-virtualization-colinux/

Advantages of coLinux
coLinux is a great way to use and experiment with Linux. Like Cygwin, it allows you to develop and execute Linux
applications on the Windows operating system (through coLinux). You can also maintain the Linux operating system by
installing, upgrading, or removing applications with apt-get.

Unlike Cygwin, you can execute Linux applications on coLinux without rebuilding. In this respect, coLinux is a real Linux
operating system that runs (or cooperates) with the Windows operating system.

Another interesting advantage of coLinux is its portability. You can have a coLinux distribution with a custom set of
applications on a given Windows host (within the root file system). You can move the root file system to another host, and then
restart it. This allows for a mobile development platform where the compressed root file system fits on a standard Universal
Serial Bus (USB) memory stick.

Finally, coLinux is fast because it's essentially running on the native hardware.

Problems with coLinux


The primary disadvantage of coLinux is that it has the ability to crash the entire machine (all cooperating operating systems)
because the guest operating system runs in a privileged mode in the host kernel. It also has some dependencies on external
software for normal operation (windows and networking support). Outside of this, it's quite easy to install and configure. In the
many hours that I've used it, I've never seen a crash.

Summary
While there are many virtualization schemes out there, coLinux is novel in its approach and the capabilities that it provides.
coLinux by itself provides a virtualized Linux on top of Windows. With the addition of some other open source tools, you can
support a full-fledged Linux development system complete with networking and a graphical user interface. coLinux isn't
perfect, but it's a great way to use Linux on a standard Windows desktop computer.

Resources
Learn
The coLinux Web site gives the current status of the coLinux open source code for allowing a Linux distribution to run
cooperatively on top of Windows.

The coLinux wiki provides documentation and other resources for getting started with coLinux.

Dan Aloni's Cooperative Linux (PDF) paper explores some of the lower-level technical details of the coLinux
implementation.

"Virtual Linux" (developerWorks, December 2006) explores the history of virtualization and the various methods of
virtualization available for Linux.

"An Introduction to Virtualization" by Amit Singh is a great introduction to virtualization and the varying
implementations that are available. In addition to Linux, this article also covers other operating system virtualization
(Windows, Solaris) and other means of virtualization (such as network stack virtualization).

TUN and TAP are virtual network kernel drivers.

Xen is an open source virtual machine monitor (hypervisor) developed by XenSource. Xen uses what is known as
paravirtualization, which typically requires guest operating system modification, but Xen can take advantage of
virtualization CPUs to support unmodified guest operating systems.

APT is a package management system from the Debian Linux distribution. It's a great utility to keep your system up to
date.

6 of 7 9/23/2008 1:47 PM
Virtualization with coLinux http://www.ibm.com/developerworks/linux/library/l-virtualization-colinux/

In the developerWorks Linux zone, find more resources for Linux developers.

Stay current with developerWorks technical events and Webcasts.

Get products and technologies


Get the latest source and binary drops for coLinux at SourceForge.

Get the latest TUN/TAP driver at SourceForge.

KVM is a newcomer to virtualization for Linux. It's a kernel module solution that requires minimal changes to the Linux
kernel and loads as a kernel module. KVM provides the virtualization of a guest operating system, but it requires
QEMU for I/O. Read about the introduction of KVM into the 2.6.20 kernel.

Cygwin is another interesting Linux emulator that runs on Windows. coLinux can use the X server capabilities provided
by Cygwin.

Xming is an open source X windows server for the Microsoft Windows environment.

Order the SEK for Linux, a two-DVD set containing the latest IBM trial software for Linux from DB2®, Lotus®,
Rational®, Tivoli®, and WebSphere®.

With IBM trial software, available for download directly from developerWorks, build your next development project on
Linux.

Discuss
Check out developerWorks blogs and get involved in the developerWorks community.

About the author

M. Tim Jones is an embedded software architect and the author of GNU/Linux Application Programming, AI
Application Programming, and BSD Sockets Programming from a Multilanguage Perspective. His engineering
background ranges from the development of kernels for geosynchronous spacecraft to embedded systems
architecture and networking protocols development. Tim is a Consultant Engineer for Emulex Corp. in Longmont,
Colorado.

Share this....
Digg this story del.icio.us Slashdot it!

Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. Microsoft, Windows, Windows
NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. Other company,
product, or service names may be trademarks or service marks of others.

7 of 7 9/23/2008 1:47 PM

You might also like