Creating Paravirtualized Domain on Xen

We have already installed Xen 4.3.0 and Domain 0.

Now Its time to create Dom U on Xen.

Lets create Paravirtualized VM.

It needs two things-
1) Kernel for new Domain.
2) File system for new Domain

Lets compile kernel version 3.7.1 for new guest domain-

user@dom0# wget
user@dom0# tar xvf linux-3.7.1.tar.gz
user@dom0# cd linux-3.7.1
user@dom0# make menuconfig

Set following parameters-

Processor type and features ?
        High memory support (64GB)
        PAE (Physical Address Extension) Support - enabled

Processor type and features ?
        Allocate 2nd-level pagetables from highmem - disabled

Verify .config file have following parameters set-


Now hit make command for kernel compilation, and it will create vmlinux kernel file.

root@dom0# make

Creating file System for Guest-

We can create empty disk of 10 GB with following commands-

user@dom0# dd if=/dev/zero of=/root/domu.img bs=1024K count=1024

Now we need to format this file system with-

user@dom0# /sbin/mkfs.ext4 /root/domu.img

Now we need to install a base system, Here I am going with Debian Squeeze. For this you need to mount disk image to any directory
and then use debootstrap command for populating image with Debian Squeeze base system.

root@dom0# mount –o loop /root/domu.img /mnt/

for 32 bit system

root@dom0# debootstrap --arch i386 squeeze /mnt/

for 64 bit system

root@dom0# debootstrap --arch amd64 squeeze /mnt/

Now you can see file system at /mnt
we need to configure this system.

Edit /mnt/etc/fstab

This file is a system configuration file that lists all available disks and disk partitions and indicates how they are to be initialized or otherwise integrated into the overall system’s file system. Here we mount the virtual disk device ‘/dev/xvda1’ on the root specifying ‘ext4’ as the file system and Also, we mount the proc file system on ‘/proc’ directory:

Put following contents-

/dev/xvda1 / ext4 defaults 0 1
proc /proc proc defaults 0 0

Edit /mnt/etc/hostname

put hostname to new system in this file.

Edit /mnt/etc/network/interfaces
following is sample DHCP configuration, alternatively you can have static IP configuration also.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp


auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static

Edit /mnt/etc/securetty add-


We need to create some devices virtual disk and hypervisor console
Execute following commands-

root@dom0# chroot /mnt
root@dom0# mknod /dev/xvda1 b 202 1
root@dom0# mknod /dev/hvc0 c 229 0
root@dom0# chown root:disk /dev/xvda1
root@dom0# exit

Edit /mnt/etc/inittab

Comment following lines

# 2:23:respawn:/sbin/getty 38400 tty2
# 3:23:respawn:/sbin/getty 38400 tty3
# 4:23:respawn:/sbin/getty 38400 tty4
# 5:23:respawn:/sbin/getty 38400 tty5
# 6:23:respawn:/sbin/getty 38400 tty6

and add

hvc0:2345:respawn:/sbin/agetty -L 9600 hvc0

Create user-

root@dom0# chroot /mnt
root@dom0# adduser xen

Set password of root user

root@dom0# passwd root

root@dom0# exit

Now we need to install kernel modules in newly created file system.
We have downloaded and compiled kernel in step 1, at path /root/linux-3.7.1

root@dom0# cd /root/linux-3.7.1
root@dom0# make modules_install INSTALL_MOD_PATH=/mnt
root@dom0# cp /root/linux-3.7.1/.config /mnt/boot/config-3.7.1

We need initrd file which is initial ram disk which

root@dom0# chroot /mnt
root@dom0# apt-get install initramfs-tools
root@dom0# mkinitramfs -o initrd.img-3.7.1-domU 3.7.1
root@dom0# exit
root@dom0# mv /mnt/initrd.img-3.7.1-domU /root/

Now, root file system for our domU guest is ready. We can unmount it from ‘/mnt’:

root@dom0# umount /mnt

Now We are done with Kernel and file system.
We need configuration file for xl create command, to create paravirtualized VM.
In this file we mention path of kernel, ramdisk.
We give disk specification, memory, no of cpus, virtual interfaces etc.

Example File is here-

kernel = '/root/linux-3.7.1/vmlinux'
ramdisk = '/root/initrd.img-3.7.1-domU'
vcpus = '2'
memory = '1024'
root = '/dev/xvda1 ro'
name = 'storage'
vif = [ '','bridge=xenbr0']
dhcp = "dhcp"
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
extra = 'console=hvc0 xencons=tty'

You can hit following command from Dom 0 to create VM.

xl create -c path-of-configuration-file

One response to “Creating Paravirtualized Domain on Xen

  1. Pingback: Xen Hypervisor Setup | Pravinchavan's Blog·

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s