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:
mount -oloop ubuntu.img ubuntu
Run debootstrap: debootstrap lucid ubuntu http://us.archive.ubuntu.com/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:
iface eth0 inet dhcp
Set a root password:
Create a xen configuration file (ubuntu.cfg):
kernel = "/boot/vmlinuz-126.96.36.199"
ramdisk = "/boot/initrd.img-188.8.131.52"
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 184.108.40.206, 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.