Install Ubuntu into a virtual-machine image and boot it using Xen.
The previous hack showed you how to set up a Xen server [Hack #90]. To make use of your newly Xen-enabled host, you need to create some domU virtual machines to run on it. In this hack, you'll set up a basic Dapper virtual machine (VM).
The VM needs both root and swap filesystems. In a production environment, these would most likely be stored on some form of shared-access filesystem, such as a SAN or similar, but, to keep things simple, for now you should create them as loopback disk images on the local disk. So start by making a couple of directories to store them in:
sudo mkdir -p /vm/vm_base$
sudo mkdir /vm/images
The root filesystem will be a 2 GB image, so first use
dd to create a disk image and then use
mkfs to set up a filesystem in it. 2 GB
should be enough space for initial testing, but if you want to vary
the size, just change the
argument, which, when multiplied by the
bs (block size) argument, determines the
total disk size.
While mkfs is running, it will complain
that vm_base.img is not a special block device
and ask if you want to proceed anyway. Say
sudo dd if=/dev/zero of=/vm/images/vm_base.img bs=1024k count=2000$
sudo mkfs.ext3 /vm/images/vm_base.img
You can create a 200 MB swap image in a similar way:
sudo dd if=/dev/zero of=/vm/images/vm_base-swap.img bs=1024k count=200$
sudo mkswap ...