Friday, January 14, 2011

Ubuntu 10.04 + Xen + Simics

The goal of my previous posts were to create a Xen 4.0.1 + Ubuntu 10.04 and run it on top of Simics 3. Well everything works great until I got to Simics and then I would get a dreaded triple fault due to MSR 0x8000020 or MSR_EFER, which appears to be a MSR for 64-bit CPUs. It does not exist on Pentium 4 machines, Simics x86 cpu, and it is unclear why that instruction was being executed. After figuring out the stack trace in Simics, I disassembled Linux and Xen and could not find a matching set of instructions. That meant the only other possibility was that grub was at fault. It seems that during the booting of a multiboot the instruction was being called. After installing grub1 onto the machine, the machine boots in Simics.

Tuesday, January 11, 2011

Creating a Xen DomU in Ubuntu

As a follow up to my previous post, where I installed Xen onto Ubuntu 10.04, in this post, I will use debootstrap to create a DomU Ubuntu 10.04 sparse image.

Begin by installing debootstrap: apt-get install debootstrap

Create a sparse image (1 GB) -- sparse is attractive as it doesn't use real disk space until the image has content: dd if=/dev/null of=ubuntu.img bs=1M seek=1024

Create an ext3 file system in the image: mkfs.ext3 ubuntu.img

Prepare for debootstrap:
mkdir ubuntu
mount -oloop ubuntu.img ubuntu

Run debootstrap: debootstrap lucid ubuntu
Add the Xen console device to init: sed 's/tty1/hvc0/' ubuntu/etc/init/tty1.conf > ubuntu/etc/init/hvc0.conf

Add network initialization to your image by adding the following or something similar to ubuntu/etc/network/interfaces:
auto eth0
iface eth0 inet dhcp

Set a root password:
chroot ubuntu
(set password)

Clean up:
umount ubuntu
rmdir ubuntu

Create a xen configuration file (ubuntu.cfg):

kernel = "/boot/vmlinuz-"
ramdisk = "/boot/initrd.img-"
memory = 64
name = "ubuntu"
root = "/dev/xvda ro"
disk = [ "file:/root/ubuntu.img,xvda,w" ]
vif = ['bridge=eth0']

The above assumes your kernel is Xen kernel, the current working directory is "/root", and your default network device is "eth0". Adjust as necessary. Also the memory is configurable, the default listed above is 64M.

Check that everything works -- assuming xen is on (verify xm list): xm create -c ubuntu.cfg

It should boot into a domain that you can log into as root.