Difference between revisions of "Running under colinux"
m (needs rewrite; see Talk page) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | {{needsrewrite}} | |
+ | [[Category:Rewrite needed]] | ||
+ | == Running under colinux == | ||
Setting up a dual-boot system is easy to do these days, but switching to linux requires a reboot. What colinux does is let you run your linux distribution under windows. They also have the option of downloading a debian or gentoo filesystem instead and using that basic linux system (it's missing lots of packages though, but they do support apt-get/emerge). This is a walkthrough for setting up colinux to work with an existing linux distribution on another hard drive partition, since it's the more complicated (and useful) of the two options. | Setting up a dual-boot system is easy to do these days, but switching to linux requires a reboot. What colinux does is let you run your linux distribution under windows. They also have the option of downloading a debian or gentoo filesystem instead and using that basic linux system (it's missing lots of packages though, but they do support apt-get/emerge). This is a walkthrough for setting up colinux to work with an existing linux distribution on another hard drive partition, since it's the more complicated (and useful) of the two options. | ||
Line 33: | Line 35: | ||
- run the batch file and create some linux scripts <br> | - run the batch file and create some linux scripts <br> | ||
run the .bat file just created and see that everything works. now create a couple of linux scripts for convenience. I created /usr/bin/colinuxnet.sh to start the network, /usr/bin/off.sh to shutdown, and a config file /etc/colinuxdisplay to set the DISPLAY environment variable. <br> | run the .bat file just created and see that everything works. now create a couple of linux scripts for convenience. I created /usr/bin/colinuxnet.sh to start the network, /usr/bin/off.sh to shutdown, and a config file /etc/colinuxdisplay to set the DISPLAY environment variable. <br> | ||
− | <nowiki>#</nowiki>!/bin/sh <br> | + | <nowiki>#</nowiki>!/bin<nowiki>/</nowiki>sh <br> |
− | <nowiki>#</nowiki>/usr/bin/colinuxnet.sh <br> | + | <nowiki>#</nowiki>/usr<nowiki>/</nowiki>bin<nowiki>/</nowiki>colinuxnet.sh <br> |
ifconfig eth0 192.168.1.4 && route add default gw 192.168.1.1 <br> | ifconfig eth0 192.168.1.4 && route add default gw 192.168.1.1 <br> | ||
− | <nowiki>#</nowiki>!/bin/sh <br> | + | <nowiki>#</nowiki>!/bin<nowiki>/</nowiki>sh <br> |
− | <nowiki>#</nowiki>/usr/bin/off.sh <br> | + | <nowiki>#</nowiki>/usr<nowiki>/</nowiki>bin<nowiki>/</nowiki>off.sh <br> |
shutdown -h now <br> | shutdown -h now <br> | ||
Line 104: | Line 106: | ||
That should be all there is to it to get codeblocks running under colinux (after compiling codeblocks under linux of course). <br> | That should be all there is to it to get codeblocks running under colinux (after compiling codeblocks under linux of course). <br> | ||
− | + | == Compiling from source == | |
The reason to want to do this is if you want to use a different kernel than the one provided by the colinux installer (currently 2.6.11). If you want to compile your own modules or add something to the kernel then this might be the way to go. If you just try to compile a new kernel and then run it under the existing colinux binaries you will get an ABI mismatch unless you compiled with their version of gcc they used (3.3.x) to cross compile the colinux binaries, so it's probably best to just setup your own cross compiler under linux and recompile the source. Note that colinux runs in kernel mode, but does not allow linux to do direct hardware access. It writes a layer and then hands hardware requests to windows. So no sound output is supported (yet) and X doesn't run under linux (yet - but you can use xmingw as described above). It's best not to modify the kernel settings from what the colinux .config file provides too much. You will need a working linux installation and an internet connection to compile from source. <br> | The reason to want to do this is if you want to use a different kernel than the one provided by the colinux installer (currently 2.6.11). If you want to compile your own modules or add something to the kernel then this might be the way to go. If you just try to compile a new kernel and then run it under the existing colinux binaries you will get an ABI mismatch unless you compiled with their version of gcc they used (3.3.x) to cross compile the colinux binaries, so it's probably best to just setup your own cross compiler under linux and recompile the source. Note that colinux runs in kernel mode, but does not allow linux to do direct hardware access. It writes a layer and then hands hardware requests to windows. So no sound output is supported (yet) and X doesn't run under linux (yet - but you can use xmingw as described above). It's best not to modify the kernel settings from what the colinux .config file provides too much. You will need a working linux installation and an internet connection to compile from source. <br> |
Latest revision as of 14:11, 9 July 2006
Please refer to the Talk page and / or history for rewrite reasons.
Running under colinux
Setting up a dual-boot system is easy to do these days, but switching to linux requires a reboot. What colinux does is let you run your linux distribution under windows. They also have the option of downloading a debian or gentoo filesystem instead and using that basic linux system (it's missing lots of packages though, but they do support apt-get/emerge). This is a walkthrough for setting up colinux to work with an existing linux distribution on another hard drive partition, since it's the more complicated (and useful) of the two options.
- download colinux [1] That's the 5/24/05 snapshot under Development Snapshots from the homepage. It's stable as far as I can tell and they've fixed a couple major bugs since stable.
- run the installer
check everything except uncheck "Root Filesystem image Download"
install to c:\coLinux and not c:\Program Files\coLinux, since /dev paths are relative to the installation directory
don't bother downloading and installing WinPCAP (the included TAP driver works fine)
hit "continue anyway" for the tap driver installation
goto Network Connections under control panel and right click on the newly installed LAN connection (TAP-Win32 Adapter V8 (colinux)). You may want to set configure->advanced->media status to "always connected". Set the ip (tcp/ip properties) to a new ip address on your lan. E.g. my hardware firewall my internet address 68.x.x.x. Then one computer gets 192.168.1.2 and the other one (wireless connection) gets 192.168.1.3. They both set the gateway field to 192.168.1.1 (configured in the hardware firewall settings). So I set the TAP adapter ip to 192.168.1.4, it's gatway to 192.168.1.1 and the dns servers to those given to me by my isp (68.x.x.x). Now select both your network connection and the TAP lan connection (ctrl-click) and then right click on one of them and select Bridge Connections. Now right-click the Network Bridge and set the tcp/ip address to the same one your internet connection uses (192.168.1.3 here). Also put in the dns servers and gateway. You may need to right-click the Network Bridge and click Disable followed by Enable to get the connection working. What happens is that your windows internet connection is still the same ip (192.168.1.3) but from within colinux, your TAP eth0 connection will use the new ip given to the TAP connection (192.168.1.4). So colinux looks like a new box on your LAN.
- create a configuration script
first you need to find out which partitions your linux distribution uses as seen by windows. download either Dmdiag.exe from Microsoft or WinObj.zip from Sysinternals.
[2]
[3]
usage:
dmdiag > out.txt
winobj -
check \GLOBAL?? for the name of your windows partitions (C:, D:). I have \Device\HarddiskVolume1 and \Device\HarddiskVolume2 for C: and D:. The next partition is probably the linux one. Goto \Device\Harddisk0 to see all the partitions on the disk.
now create a batch script (c:\coLinux\colinux.bat) to launch colinux:
colinux-daemon.exe -t nt mem=256 kernel=vmlinux hda6=\Device\Harddisk0\Partition3 hda7=\Device\Harddisk0\Partition4 root=/dev/hda6 eth0=tuntap cofs0=c:\coLinux 3
This means use the standard NT console (better because you can cut&paste using the mouse), give 256mb of ram to colinux, specifies the name of the kernel, the linux partitiions, virtual ethernet adapter, and a shared directory which can be used to copy files between the colinux and windows systems.
My linux root (/) partition is /dev/hda6 and swap partition is /dev/hda7. These correspond to \Device\Harddisk0\Partition3 and \Device\Harddisk0\Partition4 under windows (note that windows doesn't reserve a partition name for the extended partition -- my linux partitions are logical and not primary partitions). The root is given to be /dev/hda6, and you can just put tuntap for eth0, which will find the TAP connection we setup. cofs0 will be the device name of the shared folder to use to transfer files to/from windows. The 3 on the end is passed to the kernel as a kernel parameter. It means enter runlevel 3 (init 3). I need to do this since my default runlevel on boot is 5 which starts KDE, but this will crash colinux since it doesn't support X under colinux.
- run the batch file and create some linux scripts
run the .bat file just created and see that everything works. now create a couple of linux scripts for convenience. I created /usr/bin/colinuxnet.sh to start the network, /usr/bin/off.sh to shutdown, and a config file /etc/colinuxdisplay to set the DISPLAY environment variable.
#!/bin/sh
#/usr/bin/colinuxnet.sh
ifconfig eth0 192.168.1.4 && route add default gw 192.168.1.1
#!/bin/sh
#/usr/bin/off.sh
shutdown -h now
#/etc/colinuxdisplay
export DISPLAY=192.168.1.3:0.0
be sure to make the shell scripts executable: chmod a+x /usr/bin/colinux.net /usr/bin/off.sh
Note that shutdown -h now is the proper way to stop colinux (don't just click the console X button). The 192.168.1.3 address is the address of my ethernet connection under windows. 0.0 specifies the first X display.
Modify /etc/fstab to mount the cofs0 windows directory:
#/etc/fstab
...
cofs0 /mnt/cofs cofs noauto,users,defaults 0 0
Notice there is no /dev prefix. This won't automount and will be mountable by normal users (and not fsck checked).
Create /mnt/cofs:
mkdir /mnt/cofs
chmod 777 /mnt/cofs (or chown username:users /mnt/cofs)
To mount:
mount /mnt/cofs
You can copy both to and from c:\coLinux now.
- setup Xming
[4]
Run the installer and don't bother to configure xlaunch. It just writes out a config file for later use but we'll just pass everything on the commandline anyway.
create some batch files to run X:
rem c:\coLinux\runx.bat
@echo off
SET DISPLAY=127.0.0.1:0.0
SET REMOTE_HOST=192.168.1.4
SET LOCAL_HOST=192.168.1.3
start C:\Progra~1\Xming\Xming.exe -query %REMOTE_HOST% -nodecoration -lesspointer -from %LOCAL_HOST% -clipboard
rem c:\coLinux\runx_multiwindow.bat
@echo off
SET DISPLAY=127.0.0.1:0.0
SET REMOTE_HOST=192.168.1.4
SET LOCAL_HOST=192.168.1.3
start C:\Progra~1\Xming\Xming.exe -nodecoration -lesspointer -from %LOCAL_HOST% -clipboard -multiwindow -ac
Remote host is the colinux host and local host is the windows host. You may need to forward TCP port 6000 on your firewall to allow colinux to communicate over TCP with the Xming server. The first batch script is for use with XDMCP ([5]). This will allow KDE to run under Xming. Details:
vi /opt/kde/share/config/kdm/Xaccess
*
This will allow access from all hosts
vi /opt/kde/share/config/kdm/kdmrc
[Xdmcp] Enable=true
Enables XDMCP
vi /usr/X11/xdm/Xservers
#:0 local /usr/X11R6/bin/X
Comment out that line so that the linux X doesn't start by default.
vi /usr/X11/xdm/Xaccess
*
Not sure if that's really needed. Same idea as the kdm/Xaccess though. I think this is similar to doing xhost +.
Note that everything still starts up and runs normally if I reboot into linux through grub/lilo. These changes didn't prevent KDE or X from starting up.
The second batch file (multiwindow) is used for when you don't want a full KDE on windows, but just want the linux consoles (alt-f4 to get multiple consoles does work) and a couple graphical linux applications to run under Xming. The -ac flag disables access control (needed since we are not using XDMCP and otherwise you get errors involving mit cookies or access denied). To test this mode:
run colinux.bat
run runx_multiwindow.bat
under linux:
. /etc/colinuxdisplay (or source /etc/colinuxdisplay)
try: ddd (assuming it's installed on your linux distro).
That should be all there is to it to get codeblocks running under colinux (after compiling codeblocks under linux of course).
Compiling from source
The reason to want to do this is if you want to use a different kernel than the one provided by the colinux installer (currently 2.6.11). If you want to compile your own modules or add something to the kernel then this might be the way to go. If you just try to compile a new kernel and then run it under the existing colinux binaries you will get an ABI mismatch unless you compiled with their version of gcc they used (3.3.x) to cross compile the colinux binaries, so it's probably best to just setup your own cross compiler under linux and recompile the source. Note that colinux runs in kernel mode, but does not allow linux to do direct hardware access. It writes a layer and then hands hardware requests to windows. So no sound output is supported (yet) and X doesn't run under linux (yet - but you can use xmingw as described above). It's best not to modify the kernel settings from what the colinux .config file provides too much. You will need a working linux installation and an internet connection to compile from source.
- grab the source [6]
- switch to linux
I actually recompiled everything from within colinux which works fine. You could also reboot into linux.
- extract the source and compile
I used /usr/src as the base directory. You can use /home/username if desired.
cd /usr/src; tar xfz stable-colinux-20050524.tar.gz cd stable-colinux-20050524
Your linux distribution needs a couple of things to be able to setup the cross compiler and compile the daemons. I needed to grab and install:
unix2dos-2.2.src.tar.gz
The configure script will let you know about any other missing dependencies (Everything else was present here: LFS & BLFS installation). Make sure you have wget installed since all needed mingw packages are fetched with it.
Edit bin/build-common.sh
GCC_VERSION="3.4.4" GCC_RELEASE="$GCC_VERSION-20050522-1" GCC_PATCH="gcc-core-$GCC_RELEASE-src-fix1.patch" MXML_URL=http://ftp.easysw.com/pub/mxml/1.3
Needed patch:
#########begin gcc-core-3.4.4-20050522-1-src-fix1.patch##########
diff -urN gcc-3.4.4-20050522-1.old/gcc/crtstuff.c gcc-3.4.4-20050522-1/gcc/crtstuff.c --- gcc-3.4.4-20050522-1.old/gcc/crtstuff.c 2005-08-18 15:46:45.000000000 -0400 +++ gcc-3.4.4-20050522-1/gcc/crtstuff.c 2005-08-18 15:53:00.000000000 -0400 @@ -602,7 +602,8 @@ #if defined (USE_EH_FRAME_REGISTRY) \ && !__USING_SJLJ_EXCEPTIONS__ static int __EH_FRAME_END__[] - __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME), +/* __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME), */ + __attribute__ ((unused, section(EH_FRAME_SECTION_NAME), aligned(4))) = { 0 }; static void __reg_frame_ctor (void) __attribute__ ((constructor));
#########end gcc-core-3.4.4-20050522-1-src-fix1.patch#########
Save the above (between the ### marks) to gcc-core-3.4.4-20050522-1-src-fix1.patch
mkdir /usr/src/download (mkdir /home/username/download if using home directory) mv gcc-core-3.4.4-20050522-1-src-fix1.patch /usr/src/download
The patch is needed for gcc 3.4.4 to compile as a cross compiler using sjlj exceptions (dwarf exceptions don't work well under windows it seems). Otherwise you get errors about the mode(SI) statement.
Compile:
./configure make make # I got md5sum creation errors, but things resumed ok -- just type make again... make install
This will download and install a mingw cross compiler under linux. It will then proceed to compile the windows colinux daemons and finally the colinux kernel. The kernel source will be in a subdirectory of the directory you are compiling from (/usr/src/linux-2.6.11-co or something). You can later recompile the colinux kernel by switching to this directory and doing:
make menuconfig # set kernel options...don't change too much or it may not work with colinux make vmlinux make modules modules_install # installed to /lib/linux-2.6.11-co i believe
Then just move the /usr/src/linux-2.6.11-co/vmlinux kernel image to c:\coLinux (backup the old one in case). Fyi, the kernel patch they are using is under stable-colinux-20050524/patch/linux and the kernel .config file is stable-colinux-20050524/config/linux-config
(tar xfz linux-2.6.11-12.tar.gz; cd linux-2.6.11-12; patch -p1 -i
stable-colinux-20050524/patch/linux; cp stable-colinux-20050524/config/linux-config .config)
to start from fresh kernel.org sources. note that only up to 2.6.11-X is working. A patch is available on colinux.org for 2.6.12 but I haven't tried it.
Btw the make install above just installs to a subdirectory (dist/). It won't touch /usr or /usr/local. Once everything completes you can just tar the dist directory and copy to your windows directory:
tar cfz dist.tar.gz dist mount /mnt/cofs mv dist.tar.gz /mnt/cofs
Winrar supports extracting from .tar.gz and .tar.bz2 archives (7zip does too I believe).
That's all that should be required to build colinux from source and compile custom colinux kernels.
Make sure you use the same gcc major version (gcc 3.4.x here) to compile both the daemons and kernel (the automatic kernel build run by the colinux install scripts does this by default).