coLinux allows you to run a full Linux distribution, such as Ubuntu Hardy, on top of Windows at near native speeds. It runs as a single Windows process with its own specially allocated address space. The guest linux system can run from either a separate disk partition or from a single file on your Windows filesystem.
My initial impression of coLinux was so positive, I had planned to name this post, Goodbye Cygwin, hello coLinux. After 2 months of using coLinux, I still am using Cygwin a little bit. Despite being slow, (almost unbearably slow with my company's mandatory Whole Disk Encryption), Cygwin is good at integrating the GNU tools with Windows. Currently, I am still using Cygwin to script my Windows-only project version control system and use the Cygwin version of Mercurial for my personal version control. I'm not sure if using the Linux version of Mercurial would work on Samba shares. The more I learn about Linux and the less I depend on Windows applications, the less I will need Cygwin. (Update: Mercurial 1.0 works great on Samba shares. The important thing is to setup the owner of the share to be your user id and not root. See samba config below.)
Besides that, coLinux is great. The best part for me was being able to run the dynamic, tiling, scriptable, keyboard-driven window manager, wmii. I access Windows files (and network drives) using Samba. Shell commands, emacs, ssh are all there and are so fast. GUI applications such as Firefox, OpenOffice and Gimp are available as well. However, these are slow with the slirp networking setup. With a TAP connection between coLinux and the host OS, these apps run well, however, I couldn't get the TAP connection to work in conjuction with internet access so I settled for slirp only. If I figure this out, I will update the post. Here are my install notes.
Update 4/28/2008: I got my private TAP connection to the host working along with a slirp connection for internet. This makes my X server connections fast enough to run all my GUI apps like OpenOffice,
evincekpdf for pdf files, and my web browser. See this section for details.
- Install coLinux
- Configure CoLinux
- Run CoLinux
- Configure networking with slirp only
- Configure networking with slirp and TAP
- Update your Ubuntu Dapper installation
- Run an Xterm and other apps
- Expand the root file system image
- Upgrade to Ubuntu Hardy
- Disable some startup services
- Configure Ubuntu
- Create a home filesystem image
- Setup the swap file
- Mount Windows filesystem as Samba share
- Set up wmii window manager
- Download the coLinux installer and the Ubuntu root file system image
- Go to http://sourceforge.net/projects/colinux/files
- Under coLinux-stable, 0.7.2-linux-2.6.22, download coLinux-0.7.2.exe
- Under Root FS Images - 2.6.x-based, Ubuntu, download Ubuntu-6.06.1.ext3.1gb.bz2
- Run the coLinux Windows installer
- Accept defaults except for:
- Destination Folder: change to c:\coLinux
- You do not need to install WinPCap library.
- You will get a warning dialog saying that "TAP-Win32 Adapter V8 (coLinux)" has not passed Windows Logo testing. Click "Continue Anyway"
I already had Cygwin running so I did this stuff in a bash shell. You can use Windows commands as well to do the same thing.
c:\coLinux. (Keep a copy of this file as a backup to revert your Ubuntu filesystem if you mess things up.)
- Decompress the Ubuntu file system image. (Note, this could take a minute or more depending on your system.)
$ cd /cygdrive/c/coLinux
$ bunzip2 Ubuntu-6.06.1.ext3.1gb.bz2
- Create a swap file
$ dd if=/dev/zero of=swap_device bs=1M count=512
$ dd if=/dev/zero of=swap_device.2gb bs=1M count=2K
(In Windows, you can use
fsutil file createnew swap_device 536870912)
- Create a configuration file
$ cp example.conf colinux.conf
Edit colinux.conf and set the following:
cobd0="c:\coLinux\Ubuntu-6.06.1.ext3.1gb" cobd1="c:\coLinux\swap_device" mem=512 eth0=slirp eth1=tuntap # only needed for TAP connectionThe following items should already be set by default:
kernel=vmlinux root=/dev/cobd0 ro initrd=initrd.gz
- Open a Windows
colinux-daemon.exe -t nt @colinux.conf
(the -t nt is optional but makes it easier to copy/paste)
- login as "root" with password "root"
- Try commands such as
- To exit, use the
Configure networking with slirp only
- If you use a http proxy server to get to the internet, do the following inside the running CoLinux session:
root@ubuntu:~# echo "export http_proxy='http://your-proxy-server.com:yourportnumber'" >> .bash_profile
root@ubuntu:~# source .bash_profile
- Otherwise, there is nothing to do. The Ubuntu image already has the correct /etc/network/interfaces and /etc/resolv.conf files setup.
/etc/network/interfaces should look like this:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # 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
- To test internet access, use something like
pingdoesn't work with slirp.
root@ubuntu:~# wget www.google.com
/etc/resolv.conf should look like this:
Configure networking with slirp to internet and TAP to host
In this configuration, I set up TAP to form a private connection to the host and slirp to access the internet. If you want to use X applications, this will make the response much better than with slirp only. I had to play around with the IP addresses to find one that didn't conflict with the static IP addresses on our network. I ended up choosing "10.0.3.16" for the TAP colinux address and "10.0.3.17" for my Windows side.
- TAP should be installed when you install coLinux
- In Windows, go to "Start", "Control Panel", "Network Connections"
- Find the "TAP-Win32 Adapter V8 (coLinux)" adapter. For me, it was named "Local Area Connection 2". Right click on it and select "Properties".
- On the "General" tab, scroll down and select "Internet Protocol (TCP/IP)". Click on "Properties".
- Select "Use the following IP address:". Enter in "10.0.3.17" for the "IP address:" and "255.255.254.0" for the "Subnet mask:". Leave the rest blank. Click "OK" twice to finish.
- in coLinux, edit /etc/network/interfaces to look like the following:
auto lo # Loopback interface iface lo inet loopback # Network interface for internet access (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 # Network interface for private connection to Host OS (tap-win32) auto eth1 iface eth1 inet static address 10.0.3.16 network 10.0.3.0 netmask 255.255.254.0 broadcast 10.0.3.255
- Make sure your "colinux.conf" file has the following lines:
- You will need to set your DISPLAY variable to "10.0.3.17:0"
root@ubuntu:~# export DISPLAY=10.0.3.17:0
Update your Ubuntu Dapper installation
root@ubuntu:~# apt-get update
You can ignore the following warning:
W: GPG error: http://security.ubuntu.com dapper-security Release: Could not exec ute /usr/bin/gpgv to verify signature (is gnupg installed?) W: GPG error: http://fr.archive.ubuntu.com dapper-updates Release: Could not exe cute /usr/bin/gpgv to verify signature (is gnupg installed?) W: GPG error: http://fr.archive.ubuntu.com dapper-backports Release: Could not e xecute /usr/bin/gpgv to verify signature (is gnupg installed?) W: GPG error: http://fr.archive.ubuntu.com dapper Release: Could not execute /us r/bin/gpgv to verify signature (is gnupg installed?) W: You may want to run apt-get update to correct these problems
root@ubuntu:~# apt-get upgrade
Answer yes to prompts.
- That was easy.
Run an Xterm and other apps
Warning, getting the X Window System working properly was one of the most frustrating parts of the setup for me. The behavior seemed to be even non-deterministic. This is what worked for me. You may need to consult other sources to get it working for you. I am starting to readX Power Tools to learn more about the X Window System and will update this section if I learn anything new. I used Cygwin's X server because I already had Cygwin installed. Another option is Xming.
Update 5/6/2008: After switching to the Slirp+TAP networking configuration, I've been getting errors when trying to start my X clients:
$ xeyes No protocol specified Error: Can't open display: 10.0.3.17:0 $ xterm No protocol specified xterm Xt error: Can't open display: 10.0.3.17:0 $ urxvt No protocol specified urxvt: can't open display 10.0.3.17:0, aborting.To resolve this, I have been starting up a Cygwin bash shell, and running the
xhost +command to disable access control. This worked, but it was annoying to do this all the time. I discovered that there is a
-accommand line option to
Xwinwhich will do the same thing. I've updated my batch file below to reflect this. Here is a list of all the
Xwincommand line options:
use: X [:You can view this list by typing
] [option] -a # mouse acceleration (pixels) -ac disable access control restrictions -audit int set audit trail level -auth file select authorization file bc enable bug compatibility -br create root window with black background +bs enable any backing store support -bs disable any backing store support -c turns off key-click c # key-click volume (0-100) -cc int default color visual class -co file color database file -core generate core dump on fatal error -dpi int screen resolution in dots per inch -deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs -f # bell base (0-100) -fc string cursor font -fn string default font name -fp string default font path -help prints message with these options -I ignore all remaining arguments -ld int limit data space to N Kb -lf int limit number of open files to N -ls int limit stack space to N Kb -logo enable logo in screen saver nologo disable logo in screen saver -nolisten string don't listen on protocol -noreset don't reset after last client exists -reset reset after last client exists -p # screen-saver pattern duration (minutes) -pn accept failure to listen on all ports -nopn reject failure to listen on all ports -r turns off auto-repeat r turns on auto-repeat -render [default|mono|gray|color] set render color alloc policy -s # screen-saver timeout (minutes) -sp file security policy file -su disable any save under support -t # mouse threshold (pixels) -terminate terminate at server reset -to # connection time out -tst disable testing extensions ttyxx server started from init on /dev/ttyxx v video blanking for screen-saver -v screen-saver without video blanking -wm WhenMapped default backing-store -x string loads named extension at init time -maxbigreqsize set maximal bigrequest size +extension name Enable extension -extension name Disable extension -query host-name contact named host for XDMCP -broadcast broadcast for XDMCP -indirect host-name contact named host for indirect XDMCP -port port-num UDP port number to send messages to -from local-address specify the local address to connect from -once Terminate server after one session -class display-class specify display class to send in manage -cookie xdm-auth-bits specify the magic cookie for XDMCP -displayID display-id manufacturer display ID for request The X Keyboard Extension adds the following arguments: -kb disable the X Keyboard Extension +kb enable the X Keyboard Extension [+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ] enable/disable accessx key sequences -ar1 set XKB autorepeat delay -ar2 set XKB autorepeat interval -noloadxkb don't load XKB keymap description -xkbdb file that contains default XKB keymaps -xkbmap XKB keyboard description to load on startup -depth bits_per_pixel Specify an optional bitdepth to use in fullscreen mode with a DirectDraw engine. -emulate3buttons [timeout] Emulate 3 button mouse with an optional timeout in milliseconds. -engine engine_type_id Override the server's automatically selected engine type: 1 - Shadow GDI 2 - Shadow DirectDraw 4 - Shadow DirectDraw4 Non-Locking -fullscreen Run the server in fullscreen mode. -refresh rate_in_Hz Specify an optional refresh rate to use in fullscreen mode with a DirectDraw engine. -screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ] Enable screen scr_num and optionally specify a width and height and initial position for that screen. Additionally a monitor number can be specified to start the server on, at which point, all coordinates become relative to that monitor (Not for Windows NT4 and 95). Examples: -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600 -screen 0 1024x768@3 ; 3rd monitor size 1024x768 -screen 0 @1 ; on 1st monitor using its full resolution (the default) -lesspointer Hide the windows mouse pointer when it is over an inactive Cygwin/X window. This prevents ghost cursors appearing where the Windows cursor is drawn overtop of the X cursor -nodecoration Do not draw a window border, title bar, etc. Windowed mode only. -mwextwm Run the server in multi-window external window manager mode. -internalwm Run the internal window manager. -rootless Run the server in rootless mode. -multiwindow Run the server in multi-window mode. -multiplemonitors EXPERIMENTAL: Use the entire virtual screen if multiple monitors are present. -clipboard Run the clipboard integration module. Do not use at the same time as 'xwinclip'. -nounicodeclipboard Do not use Unicode clipboard even if NT-based platform. -scrollbars In windowed mode, allow screens bigger than the Windows desktop. Moreover, if the window has decorations, one can now resize it. -[no]trayicon Do not create a tray icon. Default is to create one icon per screen. You can globally disable tray icons with -notrayicon, then enable it for specific screens with -trayicon for those screens. -clipupdates num_boxes Use a clipping region to constrain shadow update blits to the updated region when num_boxes, or more, are in the updated region. Currently supported only by `-engine 1'. -[no]unixkill Ctrl+Alt+Backspace exits the X Server. -[no]winkill Alt+F4 exits the X Server. -xkbrules XKBRules Equivalent to XKBRules in XF86Config files. -xkbmodel XKBModel Equivalent to XKBModel in XF86Config files. -xkblayout XKBLayout Equivalent to XKBLayout in XF86Config files. For example: -xkblayout de -xkbvariant XKBVariant Equivalent to XKBVariant in XF86Config files. For example: -xkbvariant nodeadkeys -xkboptions XKBOptions Equivalent to XKBOptions in XF86Config files. -logfile filename Write logmessages to instead of /tmp/Xwin.log. -logverbose verbosity Set the verbosity of logmessages. [NOTE: Only a few messages respect the settings yet] 0 - only print fatal error. 1 - print additional configuration information. 2 - print additional runtime information [default]. 3 - print debugging and tracing information. -[no]keyhook Grab special windows key combinations like Alt-Tab or the Menu key. These keys are discarded by default. -swcursor Disable the usage of the windows cursor and use the X11 software cursor instead
Xwin --helpin a Cygwin bash shell. Also, in the process, I tried the Xming X server. However, I couldn't get it to work with wmii, so I decided to stick with Cygwin's X server.
- Edit your startxwin.bat file (located in "C:\cygwin\usr\X11R6\bin") so that it starts X in rootless mode, with clipboard support, disables access control, and doesn't run anything else. Run the new bat file.
@echo off SET DISPLAY=127.0.0.1:0.0 SET CYGWIN_ROOT=\cygwin SET RUN=%CYGWIN_ROOT%\bin\run -p /usr/X11R6/bin SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH% SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB SET XNLSPATH=/usr/X11R6/lib/X11/locale if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0 del %CYGWIN_ROOT%\tmp\.X11-unix\X0 :CLEANUP-FINISH if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix %RUN% XWin -clipboard -silent-dup-error -rootless -ac
- If you are using Slirp-only networking:
- Obtain your Windows host IP address by opening a cmd.exe shell and running
- In coLinux, set your DISPLAY variable to this IP address:
root@ubuntu:~# export DISPLAY=xxx.xxx.xxx.xxx:0.0
xxx.xxx.xxx.xxxis your IP address. Don't forget the
:0.0at the end.
- Obtain your Windows host IP address by opening a cmd.exe shell and running
- If you are using TAP plus Slirp configuration described above, set your DISPLAY variable to "10.0.3.17:0"
root@ubuntu:~# export DISPLAY=10.0.3.17:0
root@ubuntu:~# apt-get install xterm
Answer yes to prompts.
Xterm comes up!
- You can now install and run other high level apps like firefox or emacs
Expand the root file system image
You will need to expand the size your root filesystem image to hold the larger Ubuntu installation. I expanded it to 4GB for Xubuntu Hardy and am currently using about 87% of that. You might want to expand it to 5GB or more especially if you will be installing a lot of apps. See http://colinux.wikia.com/wiki/ExpandingRoot for more information. Note, Google's calculator function can be useful for calculating block sizes. (e.g. entering in
4GB / 16KBinto the Google search box returns: (4 gigabytes) / (16 kilobytes) = 262 144)
- If you have coLinux running, shut it down, with
- In a Cygwin bash shell, make a copy of your current image.
$ cp Ubuntu-6.06.1.ext3.1gb Ubuntu-6.06.1.ext3.4gb
This may take a while.
- Expand the new file:
$ dd bs=16384 if=/dev/zero of=Ubuntu-6.06.1.ext3.4gb seek=65536 count=262144
bs=16384 sets the blocksize to 16KB
seek=65536 skips the first 65536 blocks (1GB/16KB = 65536)
count=262144 adds 262144 blocks to the image (4GB/16KB = 262144)
This may take a while also. It should display the following when complete:
262144+0 records in 262144+0 records out 4294967296 bytes (4.3 GB) copied, 154.362 s, 27.8 MB/s
- Change your colinux.conf file to use the new file system image:
- Switch back to the cmd.exe console, and start coLinux again
root@ubuntu:~# apt-get install ext2resize
root@ubuntu:~# ext2online /dev/cobd0
- Look at your available space:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/cobd0 4128448 411148 3507624 11% / varrun 128096 36 128060 1% /var/run varlock 128096 0 128096 0% /var/lock devshm 128096 0 128096 0% /dev/shm
- Note, you may want to make a backup copy of your new expanded root file system image at this point in case things get hosed up later on. Be sure to
haltcoLinux first. Note, this will take even longer than the 1gb filesystem copy.
Upgrade to Ubuntu Hardy
Update 4/28/2008: When I first installed coLinux, Ubuntu Gutsy was the latest release. Because there was no direct upgrade path from Ubuntu 6.06 Dapper to Ubuntu 7.10 Gutsy, I had to incrementally upgrade from Dapper to Edgy, Edgy to Feisty, and Feisty to Gutsy. Later, when Hardy came out, I upgraded from Gutsy to Hardy. If you are upgrading to Dapper to Hardy for the first time, you can use the incremental method, or the direct method. Ubuntu supports a direct upgrade from 6.06 Dapper Drake to 8.04 Hardy Heron because both are Long Term Support (LTS) releases. See the Ubuntu upgrade documentation for more information. Note, I did not test the direct upgrade method.
- In coLinux:
root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get install ubuntu-minimal
root@ubuntu:~# apt-get install ubuntu-standard
root@ubuntu:~# apt-get install xubuntu-desktop
- Edit your sources.list file and change "dapper" to "edgy"
root@ubuntu:~# nano /etc/apt/sources.list
root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get upgrade
root@ubuntu:~# apt-get dist-upgrade
- Change "edgy" to "feisty" in /etc/apt/sources.list and repeat steps 6-8.
- Change "feisty" to "gutsy" in /etc/apt/sources.list and repeat steps 6-8.
- Change "gutsy" to "hardy" in /etc/apt/sources.list and repeat steps 6-8.
- Remove unneeded packages:
root@ubuntu:~# apt-get autoremove
Disable some startup services
This is optional but may give you fewer warnings. In coLinux, go to the /etc/rc2.d directory and follow the instructions in the README file for disabling services. Here are some suggested services to disable:
- acpid, acpi-support, apmd: used for power management
- bluetooth: used for bluetooth
- hotkey-setup: used to configure laptop hotkeys
- pcmciautils: tools for PCMCIA cards (PC cards)
- powernowd: controls CPU speed and voltage using the sysfs interface
- vbesave: used to save the video card state
- Don't start gdm (the display manager which starts the X server)
root@ubuntu:~# mv /etc/rc2.d/S13gdm /etc/rc2.d/K87gdm
- Set the timezone
Start your Cygwin X server if it is not already running.
root@ubuntu:~# time-admin &
Set your timezone.
- Set the root password
- Set local machine name:
root@ubuntu:~# nano /etc/hostname
root@ubuntu:~# nano /etc/hosts
- Create a user account
root@ubuntu:~# adduser sofeng
Note, adduser is a higher level command than useradd. adduser will set up a group and home directory.
- Set permissions on /dev/tty* (Note: not sure if this is needed)
root@ubuntu:~# chgrp tty /dev/tty*
Edit /etc/group to have the following line:
- Make a pty device
root@ubuntu:~# cd /dev
root@ubuntu:~# MAKEDEV pty
- Add environment variables to .bash_profile
printenvcommand to list your environment variables.
Create a home filesystem image
- Create a 10GB blank file. In Cygwin,
$ dd if=/dev/zero of=home-fs-image.10gb bs=1M count=10K
- Add the following to your c:\coLinux\colinux.conf file:
- Restart coLinux, then do the following:
Create an ext2 file system on the new disk image
root@ubuntu:~# mke2fs -F /dev/cobd2Turn this into an ext3 filesystem
root@ubuntu:~# tune2fs -i 0 -j /dev/cobd4
- Mount the new filesystem to /home
root@ubuntu:~# mv /home /home_backup root@ubuntu:~# mkdir /home root@ubuntu:~# mount /dev/cobd2 /homeCheck it worked:
- To mount the filesystem automatically at startup, add the following line to your /etc/fstab:
/dev/cobd2 /home ext3 defaults 0 0
Setup the swap file
- Add the following to /etc/fstab:
/dev/cobd1 swap swap defaults 0 0
- Initialize the swap partition
root@ubuntu:~# sudo mkswap /dev/cobd1
- make use of swap now, without rebooting system:
root@ubuntu:~# swapon -a
- Check that swap total is non-zero:
Mount Windows filesystem as Samba share
- Setup Windows networking:
- In Windows Explorer, right click on your C: drive and select "Properties"
- Click on the "Sharing" tab
- Select "Share this folder". Set the "Share name:" to "E$". Setup "Permissions" as necessary.
- create the location for your samba share:
$ sudo mkdir -p /mnt/cdrive
- add the following to /etc/fstab:
//yourcomputer.example.com/E$ /mnt/cdrive smbfs auto,user,rw,dir_mode=0777,file_mode=0777,uid=sofeng,gid=sofeng,credentials=/etc/smb-credentials 0 0
/mnt/cdriveis the mount point
smbfsmeans it is a samba filesystem type
automeans it will be mounted at startup
usermeans any user can mount it
rwmeans it will be readable and writable
file_mode=0777specifies that files will be readable, writable, and executable by everyone (this replaces the deprecated fmask)
dir_mode=0777specifies that directories will be readable, writable, and executable by everyone (this replaces the deprecated dmask)
uid=sofengmeans the owner is sofeng
gid=sofengmeans the group is sofeng
credentials=/etc/smb-credentialsspecifies the file that contains the user name and password
- create /etc/smb-credentials
$ sudo chmod 600 /etc/smb-credentails
- Mount the drive:
$ sudo mount /mnt/cdrive
Set up wmii window manager
- Install wmii window manager
apt-get install wmii
- I use emacs so the following steps are used to change the mod key.
- Download KeyTweak for Windows and remap your "Left Windows" key to "Context Menu".
- Use xmodmap to setup the "Menu" key to be "mod4". For my keyboard, my
~/.Xmodmapfile looks like this:
clear mod4 keycode 115 = keycode 127 = keycode 117 = Super_L add mod4 = Super_LThen run xmodmap in one of your startup scripts (.xinitrc, .bash_profile, etc.)
Your blog's content is excellent and quite helpful. Your site is now in my bookmarks, and I've just recommended this post in my blog.
Keep up the good work.
Some notes. You can use cofs to access the windows disk and then you do not need samba, it is faster and easier, though cofs is still maturing. Personally I found pcap-bridged networking easiest and most powerful. But newer colinux's include ndis-bridged which is very similar except it does nto require installing winpcap. The only trick with bridged networking is you must find the adapter name.pcap-bridging does not work with most wifi - but ndis-bridging might. I avoid cygwin - while it is an excellent project, trying to do complex tasks requires learning too much cygwin specific idiosyncracies. Colinux IS linux, not psuedo linux. and the mkfile.exe tool allows creating large empty windows sparse files for colinux disk and swap files. You can create an empty colinux root file system of 10GB copy your old root onto it, and it will only use the windows disk space you actually use - so if it is 25% full it will only use 2.5GB within windows.
I spent the last couple of days trying to get this thing working (btw, coLinux is so cool, but the networking setup is a pain in the ass). Your tips saved the day! Thank you very much.