PV and HVM Virtualization

From PrgmrWiki
Revision as of 00:42, 4 February 2018 by Cmb (talk | contribs) (Created page with "= The Poor Man Method of PV to HVM Conversion = A number of customers have expressed interest in converting Xen instances from PV to HVM. That process requires both changes t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Poor Man Method of PV to HVM Conversion

A number of customers have expressed interest in converting Xen instances from PV to HVM. That process requires both changes to the Xen configuration for the VPS on our server and changes to the operating system that is running inside the instance. We do have some scripts for making the required changes to the OS, but they won't work with all distributions. In fact, the only distribution that they are guaranteed to support is CentOS 7. Even for CentOS 7, the scripts do not work in many situations. For example, having more than one partition will cause the scripts to fail. Writing a capable and universal script for making bootloader changes turns out to be a difficult problem. However, we recently came up with a new strategy for PV to HVM conversions which requires minimal changes to the operating system. For many distributions, it requires no change at all. For lack of a better term, we have been referring to this as the "poorman conversion" method in internal discussion, though "quick and dirty" would be equally descriptive. If we did a PV to HVM conversion for you, and we told you that we used the poor man method, this wiki page is for you! Here is how it works.

After performing the necessary changes and migration for Xen on our end, we set your new HVM VPS to boot using a CD image. If you used pv-grub for your PV instance, that CD image contains the Grub Legacy bootloader, I.E., version 0.97. If you used grub2, it contains GRUB 2. The bootloader chain-loads the configuration file on your disk, booting what used to be a PV instance in HVM mode. This takes advantage of the fact that for a PV instance, the bootloader configuration is always stored in partition 1. We always know where to find it, so we can chainload it from the bootloader on the CD.

One problem with this approach is that the device used for a PV console differs from the device used for the HVM console. The PV console device is hvc0, but an HVM VPS uses a serial console: ttyS0. While we are converting a VPS, one of our scripts edits the bootloader configuration in-place, replacing occurrences of hvc0 with ttyS0. This should always work, but there are likely a few outliers where it might not. There is an extremely high probability that after this edit, the kernel boot messages will appear on the correct console, ttyS0. However, the login prompt might still go to the PV console, hvc0. We've decided that for people using this conversion strategy, we will expose both the HVM and the PV console. This only works if your kernel provides the hvc0 device when it is booted under HVM, but some kernels do not provide it. See the distribution-specific notes for more details. If your instance was converted with the "poor man" method, the main menu of its management console will have an option to connect to the PV console. Use that if you are not seeing output on the normal out-of-band console.

Special Configuration Changes

For most distributions, this solution works out of the box, requiring no configuration changes by the customer. However, in some cases, changes are required. Through testing and experimentation, we have determined the necessary action for each of our supported distributions. If your distribution is not mentioned in the notes below, and it is one of the distributions for which we provide images, you can safely assume that it works out of the box. All of the actions described in these notes must be performed with root privileges, E.G., using sudo.

CentOS 6 should work out of the box with no changes. If it does not, make sure that your bootloader configuration, /boot/grub/menu.lst, contains no splashimage lines and that hvc0 is replaced with ttyS0 in the boot entries.

Debian 7.0 does not provide a PV console device. Also, the console is listed in /etc/inittab. Edit your /etc/inittab, replacing references to hvc0 with ttyS0.

For Debian 8.0 Jessie with sysvinit and Debian 9.0 Stretch with sysvinit, edit inittab and replace occurrences of hvc0 with ttyS0.

Ubuntu 14.04 will print kernel messages to the HVM console, but the login prompt will be displayed on the PV console. Copy the file /etc/init/hvc0.conf to /etc/init/ttyS0.conf, and replace occurrences of hvc0 with ttyS0 in /etc/init/hvc0.conf. Then execute:

sudo service start ttyS0

Extended Boot Options

If your instance was converted with the poor man method, you will notice some extra boot options in the "set bootloader or rescue mode" menu of the management console. The first two set the VPS to boot from a GRUB Legacy or GRUB 2 CD image. You can switch between GRUB Legacy and GRUB 2, just like you could switch your PV instance between pv-grub and grub2. Option 3 is the "boot from disk" option available with all HVM VPSes. You should only use this once you have installed a bootloader directly to your disk. All of the remaining boot options are the same as those used for other HVM VPSes. Note that if you reinstall the operating system using the "install new OS image" selection from the main menu, both the option to access the PV console and the additional options in the "set bootloader or rescue mode" menu will disappear. Reinstalling an OS image effectively resets the state of your VPS, because this operation is guaranteed to install a usable bootloader to the disk.


If you have any problems, questions, or feedback, please write to us at support@prgmr.com.