How to migrate paravirtualized DomU CentOS from XEN NetBSD Dom0 to XCP-NG

How to migrate paravirtualized DomU CentOS from XEN NetBSD Dom0 to XCP-NG

Recently I had to migrate all machines from old R520 Dell Server running very dated XEN installation on NetBSD as Dom0.

Here is uname from it:

# uname -a
NetBSD hostname.hostname 6.99.24 NetBSD 6.99.24 (XEN3_DOM0) #0: Wed Oct  2 09:54:05 UTC 2013 amd64

There were couple of NetBSD DomU guests, one Windows and one CentOS PV

Because of how NetBSD handles disks for VMs - image files, partitions of bigger disks or chunks from disk pool called wedges there is no easy way to just migrate machines. XCP-NG uses VDI on LVM for disks handling.

Easiest machines were NetBSDs. I just created similiar machines in terms of disks layout on XCP-NG and just rsynced it live. Then shutdown on old server and started on new, next rsynced differential.

Windows machine had disks in image file so I transfered this image to temporary machine on XCP-NG, when second disk was connected and using dd copied it sector by sector to new disk.

On NetBSD helper machine is as simple as this:

dd if=win10.img of=/dev/rxvd1d

Note that xvd is name of disk device in NetBSD on XEN, r is for using disk as raw block device, and d and the end is "whole disk".

After that mounting this disks to new machine got my Windows system back without any quirks.

Last kind of machine was little bit tricky. First - it was CentOS running as PV gust on NetBSD host. It used pygrub to boot and its modified kernel was inside NetBSD file system. Second its hdd was dk3 wedge, so it was physical chunk of bigger disk pool.

Here is snipped config of this machine

disk = [ 'phy:/dev/dk3,xvda,w']

First I needed transferable image of this disk. DD comes in here to the rescue:

#dd if=/dev/rdk3 of=/usr/home/migration/wowza.img
614400000+0 records in
614400000+0 records out
314572800000 bytes transferred in 52864.839 secs (5950510 bytes/sec)

This produced 320GB image file of disk.

Next step is to create temporary machine with disk large enough to receive such an image, and with second disk that will receive its content back.

dd if=wowza.img of=/dev/rxvd1d

This is same as with Windows. But because Centos was PV guest on first server it won't boot on XCP-NG.

To make it work I had click Convert to PV on Advanced tab of this machine in Xen Orchestra, and add console=hvc0 xenconsole=hvc. Defaults are console=tty0 xenconsole=tty and this would not bring login prompt on console. System will hang up after booting to rc.local. In my case it looked like system went freez after starting certmonger.

After checking on original server in /boot/grub/menu.lst that there is console=hvc0 and tweaking it in XCP-NG system booted properly and let me log in allowing to reconfigure network for new MAC address.

Read more