(Disclaimer: I am by no means an expert with XenServer. So please don’t take anything you read here for granted. It’s my own experience and what I found in documentation and online.)
Switching a XenServer Linux VM from hardware assisted virtualization to paravirtualization nowadays is quite simple, since most Linux distributions already come with a Xen aware kernel (Ubuntu 16.04 definiely does, but you should check). So, most of what is described here is no longer necessary.
The very first thing to do, is this: Take a snapshot of your working HVM. So, if anything goes wrong, you can easily revert to the snapshot. If the VM is too large (e.g. you just virtualized a large file server), you can get away with temporarily detaching the data disks from the VM, take the snapshot and re-attach the data disks again.
Now, if you haven’t already done that, install the XenTools as described in point 30 and following of the article linked above:
- Attach the “guesttools.iso” image to the virtual DVD drive or your VM
- Goto the directory named “Linux” and run the install.sh script
- Reboot to make sure the VM still works
mount /dev/disk/by-label/XenServer\\x20Tools /mnt/cdrom
Once you have verified that, get the boot parameters from the first menu entry in /boot/grub/grub.cfg
You need:
- The kernel (or make sure that /vmlinz points to the right kernel)
- The ramdisk (or make sure that /initrd.img points to the right ramdisk)
- The boot parameters for the kernel, in particular the UUID of the root partition
You should verify that the UUID is correct otherwise you will end up with an unbootable system!
Shut down your VM.
Once you have all that, use either the script listed on the linked article or download my slightly modified version.
Log in to the console of the physical host on which the VM resides (I suggest using ssh) and execute the script.
It will ask you for the name of the VM to paravirtualize. If you are not sure, enter L to get a list.
After entering the name, you will be asked several questions. For most of them it should be safe to simply press enter and go with the default, but for one it isn’t:
Specify Kernel arguments (root=UUID=... ro quiet):
You must specify the kernel parameters, in particular the UUID of the root partition here. If you don’t your VM will not boot.
Once the script exits, everything is done. XenCenter should now show the VM as being in Virtualization mode “Paravirtualization (PV)”.
Boot the VM and enjoy.
What? It doesn’t boot? You get a grub error? OK, you did make a snapshot as I told you above, didn’t you? If yes, simply revert to that snapshot and try again, just in case you made a mistake. You did not make a snapshot? You’re an idiot. Yes, I mean that, I was an idiot too and I regretted it, why do you think I wrote the previous article Switching a XenServer VM from PVM back to HVM? Try the steps I list there and you might get lucky.