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 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:
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.

1 comment:

  1. CNC routers are a contact-based cutting process similar in concept best electric sharpener to handheld routers, with the plain benefit of getting the flexibility and suppleness present in automated CNC cutting. A CNC router is adept in cutting or engraving materials with pace and precision. Like laser cutters, might possibly} reduce materials similar to plastic, foam, wood, composites, acrylic, and is ideal for cutting steel, aluminum, and different steel plates to specifications. Because of their larger tolerance, CNC machines can produce merchandise with a extra polished look.