Migrating OpenVZ to KVM/Zen/Vmware

Hosting, Linux

I have been working through a process to easily convert OpenVZ based machines to KVM/Zen/Vmware machines.

This process does not seem to be well documented.. so I kinda woked it out myself.

It works like this:

  1. First thing you do is to install a KVM machine with the same operating system.  Preferably  the same point revision too!
  2. Now logon to your OpenVZ box and run ‘yum install mingetty’
    This will install a load of dependencies -  they are all required and provide the core functions to enable your machine to boot successfully!
  3. Edit the file /etc/inittab and add in the following:
    # Run gettys in standard runlevels
    1:2345:respawn:/sbin/mingetty tty1
    2:2345:respawn:/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

    This will enable the machine to actually get a logon prompt!

  4. Now.. sync the OpenVZ box to the new boxrsync –exclude=/etc/fstab ––exclude=/boot ––exclude=/proc ––exclude=/lib/modules/ ––exclude=/sys -e ssh ––delete –numeric-ids -avpogtStlHz / root@IPTOKVM:/

    This will copy every thing from the old box to the new box, but will exclude the kernel files that you will need to boot the machine!  Trust me.. it works!

  5. Power down your OpenVZ Box
  6. Reboot and start your KVM box.

This process has worked for me pretty much every time when migrating Centos 4.8 and Centos 5.4.  I am pretty certain that the same basic idea will work with other distros.

Enjoy!

Did you like this? Share it:
6 Comments

6 Comments

  1. natur  •  Feb 17, 2011 @9:48 pm

    Hello, if i try
    rsync -exclude=/etc/fstab -exclude=/boot -exclude=/proc -exclude=/lib/modules/ -exclude=/sys -e ssh -delete -numeric-ids -avpogtStlHz / root@IPTOKVM:/

    i GET
    rsync: Failed to exec ric-ids: No such file or directory (2)
    rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.7]
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: error in rsync protocol data stream (code 12) at io.c(601) [sender=3.0.7]

    any idea ? :)

    Regards,

  2. admin  •  Feb 17, 2011 @9:57 pm

    No idea!

    You could try logon to the ‘physical node’ and do a similar command.

    e.g. take out the forward slashes..

    so

    cd /var/lib/vz/102
    rsync -exclude=etc/fstab -exclude=boot -exclude=proc -exclude=lib/modules/ -exclude=sys -e ssh -delete -numeric-ids -avpogtStlHz ./ root@IPTOKVM:/

    Maybe the issue is on your container?

  3. Rob Thomson  •  Mar 17, 2011 @3:07 pm

    Ok.. I know what the issue is!

    WordPress is screwing up the copy paste from the example above!

    Use this:


    rsync --exclude=/etc/fstab –--exclude=/boot –--exclude=/proc –--exclude=/lib/modules/ –--exclude=/sys -e ssh –--delete --numeric-ids -avpogtStlHz / root@IPTOKVM:/

  4. roadwarrior  •  Nov 1, 2011 @6:04 pm

    i have tested this tutorial with 2 debian lenny boxes. i then got some errors with udev (/dev/pts not mounted, …). so i had to adapt your rsync-command

    rsync –exclude=/etc/fstab –exclude=/boot –exclude=/proc –exclude=/lib/modules/ –exclude=/sys –exclude=/etc/udev –exclude=/lib/udev -e ssh –numeric-ids -avpogtStlHz / root@TARGETIP:/

    I’ve added the to excludes: /etc/udev and /lib/udev
    i also had to remove the –delete option of rsync. do you think this is a bad idea, although it runs for my first tests?

  5. admin  •  Nov 1, 2011 @6:19 pm

    As long as you use a minimal install – it could be ok without the –delete.

  6. Rob  •  Nov 1, 2012 @10:37 pm

    Mentioned above. You might want to fix the display above of the dashes… for people too lazy to read the comments.


    -exclude: --exclude
    -delete -numeric-ids: --delete --numeric-ids

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>