How To Create a PV Guest VM on Ubuntu Virtual Machine with Xen hypervisor
Manually creating a PV Guest VM
=======================
In this section we will focus on Paravirtualized (or PV) guests.
PV guests are guests that are made Xen-aware and therefore can be optimized for Xen.
As a simple example we'll create a PV guest in LVM logical volume (LV) by doing a network installation of Ubuntu (other distros such as Debian, Fedora, and CentOS can be installed in a similar way).
1)
Install LVM
#sudo apt-get update
#sudo apt-get install lvm2
2)
Create Volume Group and Logical Volume.
#sudo mkdir /mnt/vmdisk
#sudo dd if=/dev/zero of=/mnt/vmdisk/mydisk1 bs=100M count=10
#sudo losetup /dev/loop1 /mnt/vmdisk/mydisk1
#sudo pvcreate /dev/loop1
#sudo vgcreate -s 512M myvolume-group1 /dev/loop1
#sudo lvcreate -L 512M -n mylogical_volume1 myvolume-group1
#ls /dev
3)
Get netboot images
#sudo mkdir -p /var/lib/xen/images/ubuntu-netboot
#cd /var/lib/xen/images/ubuntu-netboot
#sudo wget http://mirror.anl.gov/pub/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/initrd.gz
#sudo wget http://mirror.anl.gov/pub/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/vmlinuz
4)
Set up the initial guest configuration
#vim /etc/xen/ubuntu.cfg
name = "ubuntu"
memory = 256
disk = ['phy:/dev/myvolume-group1/mylogical_volume1,xvda,w']
vif = [' ']
kernel = "/var/lib/xen/images/ubuntu-netboot/vmlinuz"
ramdisk = "/var/lib/xen/images/ubuntu-netboot/initrd.gz"
extra = "debian-installer/exit/always_halt=true -- console=hvc0"
5)
Start the VM and connect to console (-c).
#sudo xm create -c /etc/xen/ubuntu.cfg
6)
List VMs
#sudo xm list
Manually creating a PV Guest VM
=======================
In this section we will focus on Paravirtualized (or PV) guests.
PV guests are guests that are made Xen-aware and therefore can be optimized for Xen.
As a simple example we'll create a PV guest in LVM logical volume (LV) by doing a network installation of Ubuntu (other distros such as Debian, Fedora, and CentOS can be installed in a similar way).
1)
Install LVM
#sudo apt-get update
#sudo apt-get install lvm2
2)
Create Volume Group and Logical Volume.
#sudo mkdir /mnt/vmdisk
#sudo dd if=/dev/zero of=/mnt/vmdisk/mydisk1 bs=100M count=10
#sudo losetup /dev/loop1 /mnt/vmdisk/mydisk1
#sudo pvcreate /dev/loop1
#sudo vgcreate -s 512M myvolume-group1 /dev/loop1
#sudo lvcreate -L 512M -n mylogical_volume1 myvolume-group1
#ls /dev
3)
Get netboot images
#sudo mkdir -p /var/lib/xen/images/ubuntu-netboot
#cd /var/lib/xen/images/ubuntu-netboot
#sudo wget http://mirror.anl.gov/pub/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/initrd.gz
#sudo wget http://mirror.anl.gov/pub/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/vmlinuz
4)
Set up the initial guest configuration
#vim /etc/xen/ubuntu.cfg
name = "ubuntu"
memory = 256
disk = ['phy:/dev/myvolume-group1/mylogical_volume1,xvda,w']
vif = [' ']
kernel = "/var/lib/xen/images/ubuntu-netboot/vmlinuz"
ramdisk = "/var/lib/xen/images/ubuntu-netboot/initrd.gz"
extra = "debian-installer/exit/always_halt=true -- console=hvc0"
5)
Start the VM and connect to console (-c).
#sudo xm create -c /etc/xen/ubuntu.cfg
6)
List VMs
#sudo xm list