Convert Proxmox VE OpenVZ Guest To RHEV (or anything else virt-v2v or virt-p2v does'nt support)

Posted on

I posted this as a comment to article #1134343 (https://access.redhat.com/solutions/1134343) but thought it might be more useful here.

Conventions: I refer to "source" machine as the one you want to copy or convert, and the "target" machine as the new clone of that machine which you'll host in RHEV.

Create a new VM (your target machine) in RHEV, as similar as possible to your source machine. Install your OS (RHEL 5, 6), preferably at the same point release (e.g. RHEL 5.9). Give this machine a static IP address different from your source machine, but on the same network or subnet. That IP will only be used during the data transfer.

Login to your source machine and run:

yum install mingetty

Then edit /etc/inittab, adding the following to the end:

#   Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:resspawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

Create this file at root (/):

/exclude-list.txt

It should have the following contents:

etc/fstab/
boot/
proc/
lib/modules/
etc/udev/
lib/udev/
sys/

Change directory into / and run this:

rsync –-delete –-numeric-ids --exclude-from 'exclude-list.txt' -e ssh -avpogtStlHz / root@<IP_of_target_machine>:/

(Prior to this you may need to edit sshd config on target to allow root access.)
This will copy over everything to your target machine except the kernel files that it needs to keep. When the rsync completes, shut down your source machine and power on your target machine. You should have a bootable system that is for the most part an identical copy of your original. You may need to tweak the network configuration as the NIC (and MAC address) will be different.

This could be described as a blunt-force way to clone any (running and network-accessible) Linux based machine to different hardware, virtual or otherwise. Using virt-v2v or virt-p2v is certainly a cleaner way. But this will work in a pinch. Hope that helps!

I can't take credit for coming up with the basic procedure. I got it from here with minor modifications applicable to RHEV:
source of original concept
and...
another source of original concept

Best,
Daniel

Responses