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, evince
kpdf for pdf
files, and my web browser. See this section
for details.
Ubuntu-6.06.1.ext3.1bg.bz2 to c:\coLinux.
(Keep a copy of this file as a backup to revert your Ubuntu filesystem
if you mess things up.)
$ cd /cygdrive/c/coLinux$ bunzip2 Ubuntu-6.06.1.ext3.1gb.bz2
$ dd if=/dev/zero of=swap_device bs=1M count=512$ dd if=/dev/zero of=swap_device.2gb bs=1M count=2Kfsutil file createnew swap_device 536870912
)
$ cp example.conf colinux.confcobd0="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
cmd.exe shellcd c:\colinuxcolinux-daemon.exe -t nt @colinux.confls, pwd, etc.halt command.root@ubuntu:~# echo "export http_proxy='http://your-proxy-server.com:yourportnumber'" >> .bash_profileroot@ubuntu:~# source .bash_profile
# 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
nameserver 10.0.2.3
wget since
ping doesn't work with slirp.root@ubuntu:~# wget www.google.com
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
eth0=slirp eth1=tuntap
root@ubuntu:~# export DISPLAY=10.0.3.17:0
root@ubuntu:~# apt-get updateW: 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 upgradeWarning, 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 read X 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 -ac
command line option to Xwin which will do the same thing.
I've updated my batch file below to reflect this. Here is a list of all the
Xwin command 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 --help in 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.
@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
ipconfig
root@ubuntu:~# export DISPLAY=xxx.xxx.xxx.xxx:0.0xxx.xxx.xxx.xxx is your IP address. Don't forget
the :0.0 at the end.root@ubuntu:~# export DISPLAY=10.0.3.17:0
root@ubuntu:~# apt-get install xtermroot@ubuntu:~# xterm&4GB / 16KB
into the Google search box returns: (4 gigabytes) / (16 kilobytes) = 262 144)
halt$ cp Ubuntu-6.06.1.ext3.1gb Ubuntu-6.06.1.ext3.4gb$ dd bs=16384 if=/dev/zero of=Ubuntu-6.06.1.ext3.4gb seek=65536 count=262144262144+0 records in 262144+0 records out 4294967296 bytes (4.3 GB) copied, 154.362 s, 27.8 MB/s
cobd0="c:\coLinux\Ubuntu-6.06.1.ext3.4gb"
root@ubuntu:~# apt-get install ext2resizeroot@ubuntu:~# ext2online /dev/cobd0root@ubuntu:~# df
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
halt coLinux first. Note, this will take even longer than
the 1gb filesystem copy.
root@ubuntu:~# apt-get updateroot@ubuntu:~# apt-get install ubuntu-minimalroot@ubuntu:~# apt-get install ubuntu-standardroot@ubuntu:~# apt-get install xubuntu-desktoproot@ubuntu:~# nano /etc/apt/sources.listroot@ubuntu:~# apt-get updateroot@ubuntu:~# apt-get upgraderoot@ubuntu:~# apt-get dist-upgraderoot@ubuntu:~# apt-get autoremove
root@ubuntu:~# mv /etc/rc2.d/S13gdm /etc/rc2.d/K87gdmroot@ubuntu:~# time-admin &root@ubuntu:~# passwd
root@ubuntu:~# nano /etc/hostnameroot@ubuntu:~# nano /etc/hostsroot@ubuntu:~# adduser sofengroot@ubuntu:~# chgrp tty /dev/tty*tty:x:5:sofeng
root@ubuntu:~# cd /devroot@ubuntu:~# MAKEDEV ptyprintenv command to list your environment variables.
$ dd if=/dev/zero of=home-fs-image.10gb bs=1M count=10K
cobd2="c:\coLinux\home-fs-image.10gb"
root@ubuntu:~# mke2fs -F /dev/cobd2Turn this into an ext3 filesystem
root@ubuntu:~# tune2fs -i 0 -j /dev/cobd4
root@ubuntu:~# mv /home /home_backup root@ubuntu:~# mkdir /home root@ubuntu:~# mount /dev/cobd2 /homeCheck it worked:
root@ubuntu:~# df
/dev/cobd2 /home ext3 defaults 0 0
/dev/cobd1 swap swap defaults 0 0
root@ubuntu:~# sudo mkswap /dev/cobd1
root@ubuntu:~# swapon -a
root@ubuntu:~# free
$ sudo mkdir -p /mnt/cdrive
//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/cdrive is the mount pointsmbfs means it is a samba filesystem typeauto means it will be mounted at startupuser means any user can mount itrw means it will be readable and writablefile_mode=0777 specifies that files will be readable, writable, and executable by everyone (this replaces the deprecated fmask)dir_mode=0777 specifies that directories will be readable, writable, and executable by everyone (this replaces the deprecated dmask)uid=sofeng means the owner is sofenggid=sofeng means the group is sofengcredentials=/etc/smb-credentials specifies the file that contains the user name and passwordusername=yourdomain\yourusername password=yourpassword
$ sudo chmod 600 /etc/smb-credentails
$ sudo mount /mnt/cdrive
apt-get install wmii
~/.Xmodmap file 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.)
xmodmap ~/.Xmodmap
Hi Sofeng,
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.
Good info.
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'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »