Install Alpine on coLinux

From Alpine Linux
Revision as of 15:37, 15 June 2011 by Blinkkin (talk | contribs)
Jump to: navigation, search


coLinux

coLinux provides a virtualized Linux environment under Windows, much like Virtual Box or vmware. However there is much less overhead.

This is a from-scratch instruction on how to install Alpine Linux under coLinux on Windows.

Get the necessary files from colinux.org - download latest version of coLinux installer.

Run the installer (just go through the installation). I installed everything to c:\Program Files\coLinux , and will refer to it as if you do it the same way.

Download the latest version of Alpine Linux: alpinelinux.org/downloads. I recommend mini edition. coLinux supports only 32-bit platform, so we don't have much choice - pick up x86 version.

Copy Alpine Linux ISO e.g. alpine-mini-2.2.2-x86.iso to coLinux directory. We need also initrd image from CD, so extract grsec.gz (it's in boot directory) using 7-zip or other tool.

Configuration

Now create some files. Start with alpine.bat, which should look like this:

start colinux-daemon -t nt @alpine-bootstrap.conf

Next one will be alpine-bootstrap.conf - our configuration file for coLinux. You can use this as skeleton:

# Configuration to run Alpine Linux under coLinux

# Standard coLinux kernel
kernel=vmlinux

# Alpine Linux boot initrd file
# This option *MUST* be removed after Linux was installed to boot from hda1 !
initrd=grsec.gz
alpine_dev=hdc:iso9660

# Root file system (Empty file, 700MB...1GB)
hda1=alpine-root.fs
#root=/dev/hda1

# Swap file (Empty file, 64MB...256MB)
#hda2=alpine-swap.fs

# Downloaded ISO file (unchanged)
hdc=alpine-mini-2.2.2-x86.iso

# Windows directory with kernel modules
#cofs0=cofs0

# Optional settings (memory and network)
mem=256
eth0=tuntap,"coLinux"

# Terminal size
#cocon=140x60

Setup

Right now we are messing few thing, mainly disk images. You can create them using fsutil. Launch Command Prompt, switch to coLinux directory, create alpine-root.fs and alpine-swap.fs.

fsutil file createnew alpine-root.fs 1610612736
fsutil file createnew alpine-swap.fs 268435456

This will create 1.5GB image for root file system and 258MB file for swap. Values are in bites, you can use bit calculator to calculate different sizes.

Now we're ready to launch Alpine coLinux for first time, use apline.bat for that. Alpine should load, login as root and start configuration.

setup-alpine

Next we will create ext3 partition on alpine-root.fs, we need e2fsprogs for that.

apk add e2fsprogs
mkfs.ext3 /dev/hda1
apk del e2fsprogs

Mount newly created partition and start disk installation, switch off Alpine after installation.

mount /dev/hda1 /mnt
setup-disk /mnt
poweroff

Fixes

Some fixes in alpine-bootstrap.conf are needed. Comment out ISO and initrd images. Uncomment root path, alpine-swap.fs and cofs0. Create folder cofs0 and copy there kernel modules from coLinux e.g. vmlinux-modules.tar.gz. Start Alpine coLinux once again.

First thing you will notice is lack of console at boot time, fix this:

mount --bind / /mnt
cd /mnt/dev
mknod -m 660 console c 5 1
umount /mnt

Get rid of other boot warnings:

vi /etc/mdev.conf
uncomment 1st console entry
comment out 2nd console entry

vi /etc/sysctl.conf
del net.ipv4.tcp_syncookies

vi /etc/modules
remove everything

vi /etc/apk/repositories
del /media/hdc/apks

Create swap:

mkswap /dev/hda2
swapon /dev/hda2
vi /etc/fstab
add /dev/hda2	swap	swap	default	0 0

Add swap service and remove acpid:

rc-update add swap
rc-update del acpid

Copy kernel modules from cofs0:

mount cofs0 -t cofs /mnt
cd /
tar xzvf /mnt/vmlinux-modules.tar.gz

Last step to enjoying Apline coLinux is simple:

reboot

Alpine Linux is booting so fast, I had to add "sleep 2" to /etc/init.d/networking - coLinux didn't connect to TAP interface in time ;)