Jump to content


Photo

Paravirtualizing Debian

Started by Roberto Greiner , 28 May 2012 - 03:46 PM
2 replies to this topic

Roberto Greiner Members

Roberto Greiner
  • 23 posts

Posted 28 May 2012 - 03:46 PM

Hi,

I need some guide to pick a Linux-debian VM with full-virtualization and convert it to paravirtualization. Could someone point me to some guide?I did some searches and couldn't find it.

The VM is running Debian 5.0 (Lenny), and Xen is version 5.6.

Tks,

Roberto

Edited by: roberto.greiner on May 30, 2012 10:10 AM



Roberto Greiner Members

Roberto Greiner
  • 23 posts

Posted 30 May 2012 - 02:20 PM

Since nobody answered, I digged some more and managed to paravirtualize my VM with a procedure based on two different documents, with some modifications of my own. The full procedure I used was the following:

First Step: MAKE A SNAPSHOT!!!!! This procedure is prone to catastrofic problems, like your VM not booting at all, so you need a way to go back!

Second step: Preparing the VM (based on http://djlab.com/2010/10/convert-xenserver-hvm-to-pv-paravirtual/)

1. Install a Xen-aware kernel and make it the default boot option in grub.conf or menu.lst.In my case, my distro didn't have that (Debian-based OSSIM). So, I just used step 5 and installed xs-tools, which includes a proper kernel.
2. Update /etc/fstab entries – Example: replace /dev/hda1 with /dev/xvda1, /dev/hdd with /dev/xvdd, ect.
3. Update /etc/inittab – Example: Before the entry "1:2345:respawn:/sbin/getty 38400 tty1", add the following line: "co:2345:respawn:/sbin/getty hvc0 9600 linux"
4. Make sure the /boot or / partition (depending on your partition layout) has the boot flag set. THIS IS IMPORTANT!
5. Install the Xen tools from the xs-tools CD so that memory, disk, and network usage appears properly in XenCenter. As mentioned, I did this in step 1

Third step: Modifying how Xen treats the VM (based on http://forums.citrix.com/thread.jspa?threadID=151259&tstart=0)

The text below is mostly copied from the link above, with two modifications. In the final step, the original writer indicated that for Suse you should use the following command: xe vm-param-list uuid=<vm uuid> PV-args="console=ttyS0 xencons=ttyS root=/dev/xvda2". The VM won't boot with that. Use only xe vm-param-list uuid=<vm uuid> PVargs="root=/dev/xvda2" (of course, correct for your real boot partition). Also, I modified the part about thexe vm-param-set uuid=<vm uuid> PV-bootloader-args="--kernel <full path to xen kernel> --ramdisk <full path to xen initrd>" line, simplifying the text a little.

run this command to list the installed VMs:

xe vm-list

copy the uuid of the VM that you have just installed and run the command:

xe vm-param-list uuid=<vm uuid>

this command will output all the parameters available for the VM including the on that we are about to change.
the main parameter is "HVM-boot-policy", right now you should have "HVM-boot-policy=BIOS order". we need to set empty this parameter, that how xen engine knows to use a bootloader and not qemu:

xe vm-param-set uuid=<vm uuid> HVM-boot-policy=""

note: by setting the parameter HVM-boot-policy back to "BIOS order" you could boot the guest OS back to HVM, very useful in case something doesn't work well on paravirt.

note: each parameter that is set with vm-param-set can be validated by using vm-param-get command, e.g:

xe vm-param-get uuid=<vm uuid> param-name=HVM-boot-policy

this will get you the value of the HVM-boot-policy parameter. in general it is a good idea to validate each parameter you modify.

now we need to tell the xen engine which bootloader to use by setting this parameter "PV-bootloader=pygrub" (it should be empty right now) with this command:
#xe vm-param-set uuid=<vm uuid> PV-bootloader=pygrub

we also need to tell the bootloader which kernel/initrd to load by setting this parameter "PV-bootloader-args" with the following command. To identify the proper values for kernel and ramdisk, look in the VM, in the file /boot/grub/menu.lst (in case of Debian 5/OSSIM), and copy the paths indicated for "kernel" and "initrd" respectively:
#xe vm-param-set uuid=<vm uuid> PV-bootloader-args="--kernel <full path to xen kernel> --ramdisk <full path to xen initrd>"

note: there is the parameters "PV-kernel" and "PV-ramdisk" but they do not work for some reason... :(

it is possible to also add some kernel options using this parameter "PV-args" for example:

xe vm-param-set uuid=<vm uuid> PV-args="console=ttyS0 xencons=ttyS"

note: this will cause the kernel to set the serial0 as the console but you need to make sure that you add "console" to the file /etc/securetty

another parameter that need to be tweaked before we can boot is on the virtual disk of the vm or to be more accurate on the virtual block device(vbd)of the vm, so first we need to get the corolating uuids.

run the command, in order to get the list of devices attached to the vm (HD/CD):

xe vm-disk-list uuid=<vm uuid>

you should see the virtual disk(tagged as VDI) of the vm there
note: in case you are not sure which one is the HD you want ot change then go back to the XenCenter, switch to the storage tab of the installed VM and change the "name" of the HD and press apply. run again the command above and you should see the new name there.

the parameter that we want to change is not in the VID parameter but in the VBD of the disk, so in order to get the correlating uuid for the VBD copy the uuid (note: that is not the same uuid as the VM uuid! this uuid is the uuid of the Virtual disk/VDI) and run this command:

xe vdi-param-list uuid=<virtual disk/VDI uuid>

now copy the "vbd-uuids" parameter's value, that is the uuid of the correlating virtual block device of the virtual disk.
run the command:

xe vbd-param-list uuid=<Virtual Block Device/VBD uuid>

the parameter that need to be changed is "bootable", and it need to be set to true, with the command:

xe vbd-param-set uuid==<Virtual Block Device/VBD uuid> bootable=true

ok, a few more tweaking to make it work, we need to change the a few things on the guest OS, it is specific to SLES10SP1 because the way they handle boot, which usually differ from one distro to an other, so here what I have found so far:
on SLES10SP1 the root device is written inside the initrd, that cause a problem because the name of the root device is different. so before booting we will need to set the parameter PV-args to include root=/dev/xvda2 (in a condition that it is a default configuration) so that would look something like that:

xe vm-param-list uuid=<vm uuid> PV-args="root=/dev/xvda2"

Reboot your VM. It SHOULD enter as a paravirtualized VM now. If not, debug to find out what went wrong, and use that snapshot from the beggining to restore your VM and make the necessary corrections.



James Cannon Citrix Employees

James Cannon
  • 4,402 posts

Posted 13 June 2012 - 11:50 PM

Hi Roberto,

Here is a Citrix KB that may be useful:
http://support.citrix.com/article/CTX121875

Regards,
+James Cannon+