I’ve recently gotten tired of working in Cygwin‘s slow environment and was looking for something faster and more faithful to a true Unix system. I knew virtualization was an option, but didn’t want to sacrifice the accessibility and speed of working with a native application (yes, even in seamless mode).
Enter coLinux: essentially a port of the Linux kernel for Windows that lets you run Linux apps natively in Windows.
I’ve come across it from time to time in the past few years, and even noticed the impressive andLinux and Portable Ubuntu systems running on top of it. However, I was reluctant to try them out mainly because I didn’t want/need a full-blown graphical distro and Windows wasn’t nearly as enjoyable to use for long periods of time as 7 is today.
Come November 2009, I became increasingly allergic to the usual shortcomings of Ubuntu (X and Intel drivers are to blame, mostly) and I installed the retail version of Windows 7. Cygwin has always been a bittersweet solution for me, what with the (lack of) speed, protection and other inconsistencies; in general, it was very clunky, especially considering my favorite console program stopped working in Windows 7 and I had to use Cygwin with cmd.exe (ugh).
So I decided to try coLinux for the first time, and attempt to install my favorite distro: Arch Linux. This would give me a lightweight, console-only, pure Linux environment, happily co-existing along all my Windows apps. I couldn’t be happier with the prospect.
What follows is a little guide I wrote for myself to document the process, in the hopes I can help someone out as well. It guides you through the process of installing coLinux, building a brand new Arch Linux filesystem image, and performing the necessary configuration and updates. At the end, you will have a fully updated version of Arch Linux running inside Windows 7 (and probably previous versions also). So, let’s get started.
But first…
Before we begin, I’d just like to point out that this guide was compiled by following many different sources found online. The most helpful one, by far, were these series of tutorials that show the in-depth procedure of installing coLinux with Ubuntu under Windows XP, so if you want even more information about the process I might not mention here (such as updating the coLinux binaries or expanding the filesystem), that’s your best source.
Other than that, the following sites were all helpful:
- The official coLinux wiki. Some of it is a bit jumbled and not quite easy to follow, but plenty of good info there. Take a look at the Getting Started with coLinux, Network and WinPcap articles.
- Colinux and Ubuntu Linux
- Wrangling CoLinux Networking. While it refers to a much older version of coLinux, some of it is still relevant.
I’ll also make a few assumptions about you, the reader. Firstly, that you can follow directions, have some basic knowledge of Linux and don’t fear the command-line, and most importantly: have an interest in running a fast and stable Linux distribution inside Windows!
One other thing: some of the commands here need root permission to run. These were preceded by sudo, but if you don’t have it configured, you’ll have to elevate your permissions or use “su -c <command>”.
Right. Off we go.
Downloading coLinux
As of this writing, the latest version of coLinux is 0.7.5, released on October 28, 2009. This version comes with a patched Linux 2.6.22.18 kernel, but this has some issues with the up-to-date Arch distro we’re planning on running. To remedy this, we’ll download the devel version from here, which comes with a newer 2.6.25.20 kernel.
This was the specific version I installed, but if it gives you trouble, feel free to try out the stable branch or another snapshot.
When you finish downloading the ~5 MB file, go ahead and install it. I chose to keep the default installation path (C:\Program Files\coLinux) and perform a full install with all drivers available. You never know when you might need them…
Creating the Arch Linux image from scratch
For this part you will need to use a GNU/Linux system. In theory, any distro will do, but the process is much simpler within another Arch Linux system. I happen to run it on another partition, so I used the script method. If you use any other distro, you will have to use the pacman method. Either way, this is not crucial until after the filesystem image is created, so you can use whatever you like up until then.
Creating the filesystem
Fire up your favorite console app, and type away:
cd mkdir -p coLinux/image cd coLinux
Next, we’ll create a 2GB empty file.
dd bs=1M count=2048 if=/dev/zero of=arch-ext3.fs
This will be enough for Arch and will leave around 1.3GB of free space.
Next, we create an ext3 filesystem inside this file and mount it under the image/ directory created earlier.
mkfs.ext3 -J size=4 -F -m 0 arch-ext3.fs sudo mount -o loop -t ext3 arch-ext3.fs image/
Now we have our ext3 image mounted and ready to bootstrap Arch Linux.
Script method
You can use this method only within another Arch installation, because the script depends on the pacman tool. This is the preferred way because it’s very simple (a single command does the job).
First download the archbootstrap-ee script from here.
wget http://aur.archlinux.org/packages/archbootstrap-ee/archbootstrap-ee/archbootstrap-ee.sh
And all it takes to prepare a complete Arch base system is:
sh ./archbootstrap-ee.sh --target=image
This will download about 180 MB worth of packages, so be patient unless you have a fast connection. When done, skip to the Finishing up section.
pacman method
Now, unless you already have a running Arch system, things are a bit more complicated, but not by much. You can follow this method in any x86 distro of your choice.
You will need to download pacman, Arch’s package manager. There’s a statically linked binary for these purposes, and you’ll also need its configuration file and mirror list.
wget http://repo.archlinux.fr/i686/pacman-static-3.2.2-1.pkg.tar.gz wget ftp://ftp.archlinux.org/core/os/i686/pacman-3.3.3-1-i686.pkg.tar.gz wget ftp://ftp.archlinux.org/core/os/i686/pacman-mirrorlist-20090616-1-i686.pkg.tar.gz
In the likely case that the above links are broken, check the directory for updated versions and download those.
Unpack everything:
for f in *.tar.gz; do tar xvzf $f; done
Set the necessary environment for pacman:
sudo cp etc/pacman.conf /etc sudo cp -r etc/pacman.d /etc sudo mkdir -p image/var/lib/pacman sudo ln -s `pwd`/usr/bin/pacman.static /usr/bin/pacman
Edit pacman’s mirrorlist and select your desired mirror(s) by uncommenting it:
sudo vi /etc/pacman.d/mirrorlist
Now you can run pacman with the -r (–root) option to install the base system.
sudo pacman -r `pwd`/image -Sy base
Again, this will take a while depending on your Internet connection.
Finishing up
Here’s what you should have in the image/ directory at this point:
[coLinux/image]$ ls -Alh total 84K drwxr-xr-x 2 root root 4.0K 2009-11-26 10:27 bin drwxr-xr-x 3 root root 4.0K 2009-11-26 10:27 boot drwxr-xr-x 2 root root 4.0K 2009-11-26 10:34 dev drwxr-xr-x 25 root root 4.0K 2009-11-26 10:58 etc drwxr-xr-x 2 root root 4.0K 2009-07-17 23:49 home drwxr-xr-x 8 root root 4.0K 2009-11-26 10:27 lib drwx------ 2 root root 16K 2009-11-26 09:38 lost+found drwxr-xr-x 5 root root 4.0K 2009-07-17 23:49 media drwxr-xr-x 2 root root 4.0K 2009-07-17 23:49 mnt drwxr-xr-x 2 root root 4.0K 2009-07-17 23:49 opt dr-xr-xr-x 2 root root 4.0K 2009-07-17 23:49 proc drwxr-x--- 2 root root 4.0K 2009-07-17 23:49 root drwxr-xr-x 2 root root 4.0K 2009-11-26 10:27 sbin drwxr-xr-x 4 root root 4.0K 2009-07-17 23:49 srv drwxr-xr-x 2 root root 4.0K 2009-07-17 23:49 sys drwxrwxrwt 2 root root 4.0K 2009-11-26 10:27 tmp drwxr-xr-x 10 root root 4.0K 2009-11-26 10:26 usr drwxr-xr-x 12 root root 4.0K 2009-11-26 10:26 var
coLinux requires a few extra hard drive device nodes not found in Arch. To create these do:
sudo mknod image/dev/cobd0 b 117 0 sudo mknod image/dev/cobd1 b 117 1 sudo mknod image/dev/cobd2 b 117 2 sudo mknod image/dev/cobd3 b 117 3
This will give you the choice to use up to four different devices, but feel free to create more if you need to.
Next, edit fstab to mount our root partition at bootup:
sudo vi image/etc/fstab
Here add the following lines:
/dev/cobd0 / ext3 defaults 0 1 proc /proc proc defaults 0 0
You can also comment out the /dev/cdrom, /dev/dvd and /dev/fd0 lines, unless you think you’ll be using them.
Next up is Arch’s main config file. You don’t need to open it now, but you might as well get some basic settings out of the way.
sudo vi image/etc/rc.conf
Here, change HARDWARECLOCK from “localtime” to “”. This will fix errors with the hwclock tool on bootup and shutdown that happen because coLinux doesn’t have access to the hardware clock.
While you’re here, you might want to change any other setting you need, like the hostname, timezone, locale, etc. Consult the excellent Arch Wiki for the specifics. Leave the network configuration for later.
The last thing you need to do is compress the image for easier transport to your Windows system.
dd if=/dev/zero of=image/zeros rm image/zeros sudo umount image gzip -9 arch-ext3.fs
The first command will fill out the empty space left on the partition with zeros, to be able to achieve better compression. This will take a while, depending on your disk speed. Just make sure to delete the file afterwards. In the end, you’ll have a ~140 MB arch-ext3.fs.gz file containing your Arch image.
In order to save you from all the previous trouble, I’ve uploaded the compressed image here. Keep in mind that this will be an outdated version of Arch pretty soon, and you’ll have to run ‘sudo pacman -Syu’ to get everything up to date, but it still might be worth it if you don’t want to go through the image creation process yourself.
Either way, once you have your image, copy it into your coLinux directory, boot up into Windows and let’s try it out.
Booting Arch for the first time
The first thing you need to set is the Arch configuration file for coLinux. Create the file “arch.conf” in C:\Program Files\coLinux (or your installation directory) with the following contents:
kernel=vmlinux cobd0="c:\Program Files\coLinux\arch-ext3.fs" root=/dev/cobd0 initrd=initrd.gz mem=512
This will tell coLinux which kernel and filesystem to boot, use 512 MB of RAM (you can use more, but it’s not recommended, nor necessary in our case), and copy some required files from the initrd image. You can safely comment out or remove the initrd line after booting the first time, as it is not required.
To start coLinux, open Windows’ command prompt and type:
cd /program files/colinux/ colinux-daemon @arch.conf -t nt
This will boot Arch in your current console window (as opposed to coLinux’ hideous native window; remove ‘-t nt’ to use it instead).
Arch booting in coLinux
Hopefully, you will see Arch’s beautiful boot process go by rather quickly, and after some stalling when it comes to network (unless you disabled DHCP in rc.conf earlier) you’ll be left with something that looks like this:
Arch Linux 2.6.25.20-co-0.8.0 (myhost) (tty1) myhost login:
Awesome!
Login with ‘root’ and no password (hit Enter). Now all that’s left is getting Arch online, a few tweaks here and there and we’re almost done!
To proceed with the next step, shutdown arch with “halt”.
Configuring network
Depending on your needs, you might want to do things differently than what I use. coLinux has very advanced network support and there are several ways to configure your network. Below is my configuration, but if it for some reason doesn’t work for you, make sure to look around the sources I posted above or places online for other methods, of which there are plenty.
One of my biggest network requirements is that I needed my Windows machine and Arch to be able to communicate seamlessly, as if they were on the same LAN, and wanted that connection to never drop off or be affected by other interfaces.
The easiest and most secure way to accomplish this is by using the TUN/TAP driver you (hopefully) installed with coLinux. This essentially creates a virtual interface that serves as a bridge between the two systems.
First you need to configure the Windows virtual interface. In 7, go to Control Panel > Network and Internet > Network Connections. Right-click on the connection using the “TAP-Win32 Adapter” and click Rename to give it a shorter name without spaces, such as “coLinuxTAP”. Right-click on it again and go to Properties. Double-click on the TCP/IPv4 properties and choose your desired subnet and addresses. In my case, I set apart 10.0.10.2 for the Windows machine and 10.0.10.3 for Arch.
Here’s what the connection properties should look like:

IPv4 settings for the Windows TAP interface
Unfortunately, this won’t give you access to the Internet, as the TAP simply sets a local network between the two machines. Because I’m not planning on running outside services from Arch, I would need only outgoing access to the Internet. For this purpose, Slirp will do just fine.
As a sidenote, I tried using the WinPcap method a few times, but never quite managed to get it working. I read somewhere that it has issues with wireless interfaces; YMMV.
The next step is editing the arch.conf file we created earlier, to add these two lines:
eth0=tuntap,"coLinuxTAP" eth1=slirp
Finally, start coLinux-Arch again with the same process described before, and login as root. We’ll need to configure the Linux network interfaces.
Open /etc/rc.conf again in your editor of choice and page down to the Networking section. If you didn’t change your hostname before, you can do so now.
We are going to configure our interfaces like so:
#TUN/TAP interface eth0="eth0 10.0.10.2 netmask 255.255.255.0 broadcast 10.0.10.255" #Slirp interface eth1="eth1 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255" INTERFACES=(eth0 eth1)
Make sure you delete or comment out any other eth0/eth1 definitions (such as “eth0=dhcp”).
Also, add the default gateway which will be used by the Slirp interface to access the Internet.
gateway="default gw 10.0.2.2" ROUTES=(gateway)
Save rc.conf and open up /etc/resolv.conf . This is where you’ll set up your DNS servers. I recently switched to Google’s Public DNS, but I also recommend the excellent OpenDNS.
nameserver 10.0.2.3 nameserver 8.8.8.8 nameserver 8.8.4.4
The first IP is for the Slirp interface. Finally, save the file and restart the network:
/etc/rc.d/network restart
The ping command won’t work with Slirp, but you can try using wget or curl to test Internet connectivity. You should also be able to ping the Arch machine from Windows, and viceversa (if allowed in your firewall). Sweet!
Additional tips
From here, you can do all sorts of nice things.
The first order of business is to install OpenSSH in Arch. Aside from being a necessary addition to any Linux machine, it is the preferred way to access coLinux from Windows. This is because cmd.exe sucks and using it for coLinux should be done only for administrative and testing purposes. Additionally, by using an SSH client like Kitty (enhanced version of Putty) you’ll have the added flexibility of choosing your font and window size.
I also recommend you install Samba to be able to easily share files between the two machines.
An alternative shell is worth looking into as well.
Adding swap space
This is not absolutely necessary, but if you’d like you can add swap space to Arch very easily.
Simply download the image size of your choice from here (don’t worry, they’re small files that expand to the said size; 512 MB should be more than enough) and add a new disk definition in arch.conf:
cobd1="c:\Program Files\coLinux\swap_512Mb"
Next, in Arch, add a new line in /etc/fstab:
/dev/cobd1 swap swap defaults 0 0
Upon rebooting, you should have your swap partition ready to use.
Starting as Windows service
The easiest way to use coLinux is undoubtedly to have it run automatically after Windows starts, as a service. This saves you the trouble of waiting (the 10 or so seconds, but still) for Arch to start every time you want to use it, and having to leave a command window open at all times. You simply connect to it with your SSH client and disconnect when done. The service itself uses less than 10 MB of RAM with Arch running, which is pretty negligible nowadays.
Here’s how to set it up.
First, open a command prompt with administrative privileges and run the following to register the service:
cd /program files/colinux colinux-daemon.exe @arch.conf -p arch.pid --install-service "Arch coLinux"
In the last line of the output, you should see “service installed”.
Next, go to the Windows’ Services tool (Win+R > services.msc), and look for “Arch coLinux” in the list. Set it to start with “Automatic” or “Automatic (Delayed Start)”. If you can spare to wait a few minutes before using coLinux, I’ve seen choosing the latter option makes Windows start a bit faster.
For more information about running coLinux as a service look here.
Accessing Windows drives
You can also—quite easily, in fact—read and write on Windows partitions from coLinux. It’s simply a matter of adding the following two lines to your “arch.conf” file:
cofs0=c:\ cofs1=d:\
Now in Arch, edit /etc/fstab and add the following lines:
cofs0 /mnt/winC cofs defaults 0 0 cofs1 /mnt/winD cofs defaults 0 0
Just make sure to create the directories as well:
sudo mkdir /mnt/win{C,D}
This is a very simple method to share files between the two machines if you’re not fond of Samba.
Phew!
And there you have it: your own Arch Linux inside Windows. Thanks for reading this far and have fun!
I wrote most of this guide from memory, so if anything seems wrong or flat out doesn’t work, let me know. I also suggest you to consult the official documentation for both coLinux and Arch Linux, linked at the beginning, as well as searching online.
And just for clarification, I haven’t gotten rid of Cygwin. I still use it occasionally when speed or compatibility is not an issue.