HOWTO: Run Fedora Core Under Windows using CoLinux

While setting out to construct new solutions at various companies, I'm faced with the usual technology issues that plague software professionals: A shortage of hardware resources, and a tendency to favor Microsoft technologies, despite the availability of Open Source alternatives that may be better suited for the task in question.  This kind of corporate culture makes life difficult for Power Programmers who are capable of so much more if there was a Linux Machine readily available.

Resisting the temptation to bring in one of my spare Xbox-Fedora machines to the office (with a puny 64MB of RAM available), I decided to seek alternatives that would allow me to run a full Linux Distribution under my existing Windows machine.  The obvious candidates like VMware, VirtualPC, and QEmu cropped up, and I agree they would be the easiest way to solve this problem.  Unfortunately, VMware, VirtualPC, and QEmu are large frameworks that provide full hardware virtualization, which isn't quite what I'm looking for.  Running a Virtual Machine Guest is a rather bloated way to accomplish what I was looking for.

I also have Cygwin readily available on this machine, but alas, Cygwin is useless when it comes to isolating the "Linux" content away from the Windows content.  I really wanted the merits of a Virtual Machine -- having its own resource, and living on its own IP Address; and I really wanted the light-weight functionality provided by the Cygwin solution.

There just had to be a better light-weight solution out there.  As it turns out, there is a better way.

Through my research, I stumbled onto CoLinux, which is a patched kernel that runs as a Windows Executable, and has networking support. Not a bad idea at all, it sounds just like what I need.

Bummer for me, CoLinux only has a Fedora Core 1 image.  *Grumble* *Grumble* *GRRR!* So now I've got to spend a few nights tinkering around with Fedora Core and CoLinux to see what can be done to bootstrap Fedora Core 4 under CoLinux.  There's gotta be an easier way than doing a series of "Yum Update" procedures to take Fedora Core 1 up to current versions, as mentioned in the CoLinux HOWTO section.

So, here we go again.. more Fedora-related hacking for me.

Some more ideas on how to do this: A Slackware HOWTO

Disabling Data Execution Protection in WinXP

Recent Pentiums began implementing a new "No Execute" flag that can be set on certain regions of memory.  With current CPUs, you will almost certainly run into this issue.  The problem is, linux applications loaded by the CoLinux Kernel are considered data by the Windows Kernel, and thus generate a CPU Exception when the CoLinux Kernel attempts to transfer control to those regions.

You know you've run into this problem if you see a (blue-screen) message about DRIVER_IRQL_NOT_LESS_OR_EQUAL.

In order to get things working again, you need to change the noexecute WinXP boot option in C:\boot.ini:

/noexecute=optin becomes /noexecute=AlwaysOff

A Quick Jump Start Method

I managed to get this up and running quickly by taking the XFedora4 Loopback Distribution, which has an installed image of Fedora Core 4 pre-installed.  With a few minor tweaks, you can run it under CoLinux:

  • Download and install CoLinux (I use D:\CoLinuxFedora)
  • Download and unpack the "Fedora Core 1" Root Filesystem from the CoLinux download site
  • Download the XFedora Loopback files, and Unpack them
  • Copy the root_part and swap_part image files to your CoLinux area (D:\CoLinuxFedora)
  • Create a "Bootstrap" XML Configuration file that looks similar to this:
<?xml version="1.0" encoding="UTF-8"?>
<colinux>
    <block_device index="0" path="\DosDevices\d:\CoLinuxFedora\fc1_root_2gb" enabled="true" />
    <block_device index="1" path="\DosDevices\d:\CoLinuxFedora\fc4_root_part" enabled="true" />
    <block_device index="7" path="\DosDevices\d:\CoLinuxFedora\fc4_swap_part" enabled="true" />
    <bootparams>ro root=/dev/cobd0</bootparams>
    <image path="vmlinux"></image>
    <memory size="128"></memory>
    <network index="0" type="bridged" name="Local Area Connection"></network>
</colinux>
  • Launch CoLinux with this "Bootstrap" Configuration
D:\CoLinuxFedora\colinux-daemon.exe -c D:\CoLinuxFedora\fc4.colinux.xml

The basic idea here is that you want to run another Linux image (such as the Fedora Core 1 root image available on the CoLinux downloads site), while making the "Fedora Core 4" available for editing.

  • Once it's running, log in as root (No password for the FC1 root image), and tweak the FC4 image:
mkdir /FC4
mount /cobd1 /FC4
cp -apf /dev/* /FC4/dev
nano /FC4/etc/fstab (change "/dev/loop0" to "/dev/cobd0", and "/dev/loop1" to "/dev/cobd7")
  • Shutdown. Now you can create or modify your configuration XML for a Runtime setting. (Remove the fc1 image, and change the index of the fc4 image to "0"):

 

<?xml version="1.0" encoding="UTF-8"?>
<colinux>
    <block_device index="0" path="\DosDevices\d:\CoLinuxFedora\fc4_root_part" enabled="true" />
    <block_device index="7" path="\DosDevices\d:\CoLinuxFedora\fc4_swap_part" enabled="true" />
    <bootparams>ro root=/dev/cobd0</bootparams>
    <image path="vmlinux"></image>
    <memory size="128"></memory>
    <network index="0" type="bridged" name="Local Area Connection"></network>
</colinux>

 

  • Start CoLinux with the new XML. Aside from a few annoying error messages with iptables dealing with the missing modules-directory (it wants to load filter), it should start up. Since it's an XFedora pre-built image, the root password is xfedora. Please change it ASAP.

Growing the Root FileSystem (From 2gb to 4gb):

  • Copy fc4_root_part to fc4_root_2gb - this copy will be your "Rescue/BootStrap" image
  • Using Cygwin, or a Linux/UNIX environment:
dd if=/dev/zero of=fc4_root_part bs=1M count=2048 seek=2048
  • Modify your "BootStrap XML Configuration" to use "fc4_root_2gb" on index 0, and use "fc4_root_part" on index 2.
  • Start CoLinux with that XML configuration, then do this under that environment:
e2fsck -f /dev/cobd2
resize2fs /dev/cobd2
  • Shutdown the bootstrap environment. Now you can restart CoLinux with your normal XML configuration, and your Root image will be 4GB.