User:Andy/Colinux

From KitwarePublic
Jump to navigationJump to search

CoLinux

Cooperative Linux (CoLinux from now on) is a full Linux system which runs as a single process under Windows or Linux.

Download

To begin, go to CoLinux Downloads and download the latest stable release of CoLinux. If you're installing this on Windows, you might as well download the precompiled binaries, as it will save you some time and effort. While you're at this website you should download a linux image file. I suggest Debian, simply because I couldn't get Gentoo to work properly on my system, but if you're feeling adventurous you can give it a try. The following instructions will assume you chose to work with Debian, so if you're working with Gentoo you'll need to find some of this information elsewhere. In any event, when you're downloading a root filesystem image, try and locate one that isn't too large so the download will go quickly. We will resize this file later in the guide. One important note: the images tend to be compressed in .bz2 format, which Windows can't handle natively. I suggest downloading the trial version of WinRar here. Once coLinux is installed, decompress the image into your coLinux directory. It will probably have a long ugly name. Feel free to rename this file if it tickles your fancy.

While you're in a downloading mood, there's one more file that you should get, and that is a swap file. Go here and download a swap file which you think is a good size. If you don't have any idea how big of a swap file you think you'll need, 64MB will probably do just fine. This file will be compressed in the same format as your root filesystem image. Again, extract this file into your coLinux directory after installation. Again, you can rename this file if you see fit.

Installation

Once the download has completed, run the installation file. I suggest installing CoLinux in c:\coLinux, as opposed to the Windows default c:\Program Files\coLinux. This is because some of the default configuration files that come with coLinux expect the former location. At one point during the CoLinux installation it will ask you if you want to install TAP-Win32 and WinPcap. You should answer yes to both questions. These are both networking tools that coLinux needs to connect to the Internet. Also as part of the installation, it will ask you if you would like to download a root filesystem image. Answer no to this question, since you already downloaded one earlier. The rest of the installation process is fairly straightforward

Configuration

Open up c:\coLinux, or wherever you installed it. Locate a file named default.colinux.xml and open it for editing. In this xml file you'll find a line that looks something like this:

 <block_device index="0" path="\DosDevices\C:\coLinux\root_fs" enabled="true"/>

You want to change this line so it reads:

 <block_device index="0" path="\DosDevices\C:\path\to\coLinux\your-filesystem" enabled="true"/>

Where C:\path\to\coLinux is where you installed coLinux, and your-filesystem is the name of the root image, which should be in the coLinux directory.

You're also going to want to replace the line

 <block_device index="1" path="\DosDevices\c:\coLinux\swap_device" enabled="true"/>

with

 <block_device index="1" path="\DosDevices\c:\path\to\coLinux\your_swap_file" enabled="true"/>

Where your_swap_file is the swap file you downloaded earlier

Also in this configuration file you'll see a line which looks something like:

 <memory size="64" />

Feel free to change the amount of memory allocated to coLinux to suit your needs. Now there's only one last thing to change in this file. Find the tag:

 <network index="0" type="tap" />

And edit it such that it has a name associate with it:

 <network index="0" type="tap" name="Colinux TAP" />

Remember the name that you specify here. You will need to present this information later.

Connecting to the Internet

Setting up coLinux to connect to the Internet is a little tricky. It was during this point of the process that I received multiple BSODs, but lucky for you, you get to learn from my mistakes.

Follow this path: My Network Places -> View Network Connections -> Local Area Connection 1 -> (right click)Properties -> Advanced. Check the box which is labelled "Allow other network users to connect through this computer's Internet connection". If your primary Internet connection isn't called Local Area Connection 1, modify the properties of whichever connection is appropriate.

From View Network Connections you should see a new connection, probably named something boring like "Local Area Connection 2". This is the connection that coLinux uses to leech off your normal Internet connection. When you mouse over the connection the comment "TAP-Win32 Adapter V8 (coLinux)" should appear. Rename this connection to the name you specified in the config file earlier (my example was "Colinux TAP"). If you right click on this connection, and go Properties -> General -> Internet Protocol (TCP/IP) -> Properties, the IP Address should be 192.168.0.1, and the subnet mask should be 255.255.255.0. All other values should be blank. Once you've completed these steps your coLinux should be properly configured to connect to the Internet.

Running coLinux

At this point coLinux should be set up to a point where you can properly run it. To make life a little easier, make a .bat file to run coLinux with some command line arguments. Put the following in your bat file:

 colinux-daemon.exe -t nt -c your-config-file.xml

This assumes that you bat file is in your coLinux directory. This will launch coLinux, loading your config file, and opening up a terminal window. Later in the game, when you're connecting to your coLinux system with ssh or vnc, you will probably want to edit your bat file and replace "-t nt" with "-d". This will cause coLinux to run without opening a terminal window. Once you have coLinux up and running there may be one additional step you need to take to get your Internet Connection fully working. Edit the file /etc/resolv.conf and input the following information:

 nameserver 192.168.1.18
 search kitwarein.com

This information allows your coLinux system to collect to a DNS server. I'm pretty sure these numbers are static and correct, but you can check for yourself by running ipconfig /all in Windows and checking the values for "DNS Servers" and "Connection-specific DNS Suffix"


Resizing your filesystem

Earlier in this guide I suggested that you download a smaller root filesystem image, since we would probably be resizing anyways. If you feel that your coLinux system needs more disk space than what it is currently allocated, follow these steps. Before we start, it is important to note that you will need cygwin installed on the same computer to follow these directions. There's probably a way to do everything I'm doing in cygwin under Windows, but that's up to you to figure out. The following instruction are modified from a version here Note: each step below will be preceded by what environment the step is to take place under.

1. CoLinux: Shut down coLinux

 shutdown -h now

2. Windows: Cut the root file image from the coLinux directory, and paste it in a place where cygwin can touch it. ie: c:\cygwin.

3. Cygwin: Copy old root partition, adding 2g of empty blocks at end:

 dd if=/dev/zero bs=1k count=2M |
 cat Debian-20040605-mit.ext3.1610mb - > Bigger-Debian

Replace the 2 in 2M above with the number of gigabytes you are adding. Above, Debian-20040605-mit.ext3.1610mb is the name of the source file, and Bigger-Debian is the name of the resulting bigger filesystem. Note: this command will take some time.

4. Cygwin: Verify new partition file has correct contents:

 cmp Debian-20040605-mit.ext3.1610mb Bigger-Debian

This should report binary files identical up to end of 1st file: "cmp: EOF on Debian-20040605-mit.ext3.1610mb" This will also take a long time.

5. Cygwin: Verify new partition file has correct size:

 ls -l Bigger-Debian
 echo '4 * 1024 * 1024 * 1024' | bc

The number output from bc should be the size of Bigger-Debian in bytes

6. Windows: Cut & Paste the new big configuration file from the cygwin directory to the coLinux directory

7. Windows: Copy old coLinux configuration file and give it a new name.

8. Windows: Edit the new configuration file to add the new partition:

     <block_device index="2" path="\DosDevices\c:\coLinux\Bigger-Debian" enabled="true" />

The number 2 should actually be the next unused number in your configuration file

9. Windows: Boot coLinux using the new configuration file which still uses the old root partition:

 colinux-daemon.exe -c new-debian-config.xml

10. CoLinux: Check that the file system we are expanding is in fact in good shape:

 nice --adjustment=+19 e2fsck -fv /dev/cobd2

WARNING: The number 2 in /dev/cobd2 must match the number 2 in index="2" above. Check also with the mount program that /dev/cobd2 is not already mounted. If you make a mistake in choosing the correct partition number here, you will probably destroy your existing partitions! -f forces checking even if not marked dirty, -v means verbose the nice isn't really needed for a fast machine and a small filesystem

11. CoLinux: Use resize2fs in Linux to resize copied file system on new partition:

 resize2fs -p /dev/cobd2

-p for progress indication, not completely necessary

12. CoLinux: Check that the new number of blocks reported by resize2fs multiplied by the block size is correct:

 echo '1048576 * 4 * 1024' | bc

13. CoLinux: Check that the expanded file system is still in good shape:

 nice --adjustment=+19 e2fsck -fv /dev/cobd2

14. Linux: Mount the resized file system and play with it:

 mkdir /tmp/newfs
 mount -t ext3 /dev/cobd2 /tmp/newfs

run some commands to test that things are okay

 umount /tmp/newfs

15. CoLinux: Shut coLinux down to allow coLinux to use the new larger file be a superuser:

 shutdown -h now

16. Windows: Edit the new configuration file to replace old root

 <block_device index="0" path="\DosDevices\c:\coLinux\Bigger-Debian" enabled="true" />

You must comment out or remove the mention of the old root partition and change the mention of the new partition to read as above

17. Windows: Boot coLinux with the new configuration and the new root

 colinux-daemon.exe -c new-debian-config.xml

18. coLinux: Test that it works!

Logging into CoLinux with vnc

Before you try to set up anything on your new coLinux system, you should run

 apt-get update

To make sure you have the latest Debian package lists. Next up you'll want to install the X-Window display server.

 apt-get install xserver-xfree86

As this installs it will ask you a series of questions. Try to answer them to the best of your ability. Also install the following packages, along with whatever else you can't live without:

 apt-get install xfonts-base xfonts-75dpi
 apt-get install kdebase
 apt-get install konsole
 apt-get install vncserver

You can use gnome or some other windows manager instead of KDE if you want. Once you have vncserver installed start it up by running

 vncserver -geometry 800x600 -depth 16

You'll be asked to supply a password. Do so. Remember it. To connect to it, download tightVNC from the tightVNC download page. Install this program on your Windows machine, then run vncviewer.exe. It will ask you who you want to connect to. If your coLinux system is running Debian, entering "192.168.0.40:1" should work.

You can also connect to coLinux from Cygwin using ssh. Supply the same address as above. Notice that outside machines can't connect to your coLinux system. The only way you can log in is from the machine on which coLinux is installed.