Xen 
 
Home Products Support Community News
 
   

This page describes how to use Gentoo and QEMU to do Xen development. This is really useful if you're doing Linux driver, Xen tools, or some other area of development that is not hardware related. I choose Gentoo because its what I'm used to and I can use it to create a very small image. RustyRussell has done something similiar with Debian (he is where I got the idea in the first place from).

0. Choose a mirror (I'm going to use http://gentoo.osuosl.org in this document but you should choose something close to you).

1. First create a working directory. You need about 1.5G of free space.

mkdir build

2. Fetch a stage3 and portage tarball from your mirror.

wget http://gentoo.osuosl.org/releases/x86/current/stages/x86/stage3-x86-2005.1.tar.bz2
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2

3. Extract the stage3 and portage tarballs (as root) into the build directory

cd build
tar xfj ../stage3-x86-2005.1.tar.bz2
cd usr
tar xfj ../../portage-latest.tar.bz2
cd ../..

4. Copy resolv.conf into build directory

cp /etc/resolv.conf build/etc/resolv.conf

5. chroot into the build environment and update your environment

chroot build
. /etc/profile
env-update

6. emerge xen dependencies

emerge bridge-utils iptables dev-libs/gmp dhcpcd iproute2

7. Download and install Xen

8. edit /etc/fstab

nano -w /etc/fstab

Change:

/dev/BOOT               /boot           ext2            noauto,noatime  1 2
/dev/ROOT               /               ext3            noatime         0 1
/dev/SWAP               none            swap            sw              0 0

To:

/dev/hda1               /               ext3            noatime         0 1
/dev/hdb1               /mnt            ext3            noatime         0 0

9. emerge grub

emerge grub
nano -w /boot/grub/grub.conf

And add the following:

default 0
timeout 0
root (hd1,0)

title=Xen
        kernel (hd1,0)/install/boot/xen.gz com1=115200,8n1 console=com1
        module (hd1,0)/install/boot/vmlinuz-2.6-xen0 root=/dev/hda1 console=ttyS0

10. Under '# SERIAL CONSOLES' in /etc/inittab find the line:

#s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100

And change it to:

s0:12345:respawn:/sbin/agetty 115200 ttyS0 linux

11. [OPTIONAL] Disable unnecessary startup services

rc-update del netmount
rc-update del consolefont
rc-update del clock
nano -w /etc/init.d/modules
# modify start() function to return 0 immediately
# saves a bunch of time during boot

12. Set root password

passwd

13. Exit the chroot

exit

14. Prepare an image to use. Here's what I do, there's other methods

qemu-img create -f raw gentoo.img 2G
qemu -hda gentoo.img -cdrom /dev/cdrom -boot d
# start qemu with a rescue cd, fdisk /dev/hda to have 1 partition, and mkfs.ext3 /dev/hda1
# also install grub onto (hd0)

15. Get rid of portage tree (this is optional, but saves a half a gig of space)

rm -rf build/usr/portage

16. Mount partition and copy build tree

mount -oloop,offset=32256 gentoo.img /mnt
mv build/* /mnt

QEMUGentoo (last edited 2007-03-26 15:30:27 by RichQuarles)