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
saju@saju-ops:~$
ReplyDeletesaju@saju-ops:~$
saju@saju-ops:~$ sudo xm list
[sudo] password for saju:
Name ID Mem VCPUs State Time(s)
Domain-0 0 469 1 r----- 214.5
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ sudo apt-get install lvm2
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ sudo mkdir /mnt/vmdisks
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ##Create a 2GB disk
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ sudo dd if=/dev/zero of=/mnt/vmdisks/mydisk1 bs=100M count=20
20+0 records in
20+0 records out
2097152000 bytes (2.1 GB) copied, 9.97911 s, 210 MB/s
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ls /mnt/vmdisks/
mydisk1
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ls -lsh /mnt/vmdisks/
total 2.0G
2.0G -rw-r--r-- 1 root root 2.0G Mar 10 23:56 mydisk1
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ sudo losetup /dev/loop1 /mnt/vmdisks/mydisk1
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ###Create a Physical Volume
saju@saju-ops:~$
saju@saju-ops:~$ sudo pvcreate /dev/loop1
Physical volume "/dev/loop1" successfully created
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ##Create a Volume Group of 1 GB
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ sudo vgcreate -s 1024M myvolume-group1 /dev/loop1
Volume group "myvolume-group1" successfully created
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ##Create a Logical Volume of 1GB
saju@saju-ops:~$
saju@saju-ops:~$ sudo lvcreate -L 1024M -n mylogical_volume1 myvolume-group1
Logical volume "mylogical_volume1" created
saju@saju-ops:~$
saju@saju-ops:~$
saju@saju-ops:~$ ls /dev | grep vol
myvolume-group1
saju@saju-ops:~$
saju@saju-ops:~$
Hey Saju, You're South Indian na. Vanakam | Namaskaram |Namaskar(Marathi,Hindi)|
DeleteXen NetBoot Images
ReplyDelete==================
http://mirror.anl.gov/pub/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/
http://mirror.anl.gov/pub/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/xen/xm-debian.cfg
I am getting an error like this while i am trying to create virtual machine.
ReplyDeletean error has been detected while trying to use the specified ubuntu archieve mirror how can we resolve this.
Thanks
In this system i have installed xen and want to create the 1st VM.I have followed all the steps but when I apply the following step
ReplyDelete#sudo xm create -c /etc/xen/ubuntu.cfg
it does not create the virtual machine: the error is unable to open config file :/etc/xen/guest1.cfg
....................
On another system before 4 months I have created 3 virtual machine. Its working but when I want to create 4th VM its not creating due the same problem as above.
Resolving mirror.anl.gov (mirror.anl.gov)... failed: Name or service not known.
ReplyDeleteHow can I resolve this?