How To Convert Physical Systems And Xen VMs Into OpenVZ Containers (Debian Etch)

Version 1.0
Author: Falko Timme

This guide explains how you can convert physical systems (running Debian Etch) or Xen domUs (also running Debian Etch) into an OpenVZ container. This procedure should also work for converting VMware VMs, VirtualBox VMs, or KVM VMs into OpenVZ containers, but I haven't tried this. It should work for other Linux distributions as well, with minor modifications (for example, the network configuration is not located in /etc/network/interfaces if you're not on Debian/Ubuntu).

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I want to convert the physical system or Xen domU (with the IP address into an OpenVZ container. I have a second server,, where I have set up OpenVZ according to this guide: Installing And Using OpenVZ On Debian Etch. I will use the VEID 211 for the new OpenVZ container on

I will use /vz here as the OpenVZ directory, so make sure that /vz is a symlink to /var/lib/vz:


ln -s /var/lib/vz /vz


2 Converting To OpenVZ

First we create two empty directories for the new OpenVZ container 211 on server2 and also a standard OpenVZ configuration file for the new container:


mkdir /vz/root/211 /vz/private/211
cat /etc/vz/conf/ve-vps.basic.conf-sample > /etc/vz/conf/211.conf

Next we install rsync on both systems as we will use rsync to transfer the files from server1 to the OpenVZ container:


apt-get install rsync

Now let's transfer server1's files to the OpenVZ container:


rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp -e "ssh -l [email protected]" [email protected]:/ /vz/private/211/ 

This can take a few minutes, depending on the number and size of the files on server1.

Afterwards, we can configure our new OpenVZ container with the vzctl command, as you would do if you would create a new container from scratch.

OpenVZ needs to know which distribution is used in the container, therefore we must set the OSTEMPLATE value:


vzctl set 211 --ostemplate debian-4.0-i386-minimal --save 

Afterwards, you can set the network parameters and also the disk space of the new container:


vzctl set 211 --onboot yes --save

vzctl set 211 --hostname --save
vzctl set 211 --ipadd --save
vzctl set 211 --numothersock 120 --save
vzctl set 211 --nameserver --nameserver --save

vzctl set 211 --diskspace 10000000:11000000 --save

(This would set a disk space soft limit of 10GB and a hard limit of 11GB.)

If you like, you can give the container an IP address different from that used on the original system; in that case you might have to adjust a few other files in the container (e.g. Apache configuration, etc., depending on what is installed in the container). If you use the same IP address, don't forget to shut down the original system before you power on the OpenVZ container!

These are the basic settings. You can, of course, also change the other settings with the vzctl command.

Before we start the OpenVZ container, we have to do a few OpenVZ-specific changes to it:


sed -i -e '/getty/d' /vz/private/211/etc/inittab
rm -f /vz/private/211/etc/mtab
ln -s /proc/mounts /vz/private/211/etc/mtab

cp /vz/private/211/etc/fstab /vz/private/211/etc/fstab.old
grep devpts /vz/private/211/etc/fstab.old > /vz/private/211/etc/fstab
mkdir /vz/private/211/dev
mknod --mode 666 /vz/private/211/dev/ptmx c 5 2
mkdir /vz/private/211/dev/pts
cp -a /dev/ttyp* /dev/ptyp* /vz/private/211/dev/
rm -f /vz/private/211/dev/null
mknod --mode 666 /vz/private/211/dev/null c 1 3
mknod --mode 444 /vz/private/211/dev/urandom c 1 9
mkdir /vz/private/211/proc
cat /dev/null > /vz/private/211/etc/network/interfaces

That's it, you can now start the new OpenVZ container (don't forget to shut down the old system first if both are using the same IP!)...


vzctl start 211

... and set a password:

vzctl exec 211 passwd


Share this page:

Suggested articles

10 Comment(s)

Add comment


By: Anonymous

nice tutorial. very useful for users want to migrate to OpenVZ to Proxmox VE - - the easy way to OpenVZ.


By: Anonymous

I prefer to prefix the directories with "/" in the rsync command. It prevents rsync to exclude any files or directory that may contain "dev" or "proc" in the name:

 rsync -arvpz --numeric-ids --exclude /dev --exclude /proc --exclude /tmp ...


thanks for the howto!


By: Torsten

Thanks for that beautiful Howto. I had some problems and solved them this way:

  mkdir /vz/private/211/tmp

  chmod 777  /vz/private/211/tmp

  mkdir /vz/private/211/var/tmp

  chmod 777  /vz/private/211/var/tmp

  mknod --mode 666 /vz/private/211/dev/random c 1 8

  mknod --mode 666 /vz/private/211/dev/zero c 1 5

  mknod --mode 666 /vz/private/211/dev/null c 1 3

nice day


I found /dev/tty was a normal file, and several things didn't work. It looked like this:

HN:# ls -l /vz/private/221/dev/tty
-rw-r--r-- 1 root root 16 Feb 13 14:42 /vz/private/221/dev/tty

To fix this:

   rm /vz/private/221/dev/tty

   mknod --mode 666 /vz/private/221/dev/tty c 5 0

Now it's a character special file and things are better:

HN:# ls -l /vz/private/221/dev/tty
crw-rw-rw- 1 root root 5, 0 Feb 13 15:55 /vz/private/221/dev/tty

By: Noam

Work great for VMWARE!

I've converted VMware Workstation guest of  Suse Enterprise Linux 10 64bit (running WebSphere) into ProxMox OpenVZ!



Hi Noam !!! We have a server with SLES 10 like application server under VMWARE server, and migrate to OpenVZ, but have problem with it.

can you say me what method are you use for this job ?. Some tips about the setup of system ? could you help me ?

Thank in advanced. Manuel.

By: Ilya

Can anyone help with such CentOS howto ?
about migration CentOS Xen domU to OpenVZ container

By: Anonymous

Worked from xen 3.2-1 just needed to add ORIGIN_SAMPLE="" to /etc/vz/conf/211.conf Cheers, Torsten

By: Andrei

rsync: send_files failed to open "/sys/module/iptable_nat/uevent": Permission denied (13)

rsync: read errors mapping "/sys/kernel/slab/sighand_cache/aliases": No data available (61)

rsync: read errors mapping "/sys/kernel/slab/sighand_cache/align": No data available (61)

rsync: read errors mapping "/sys/kernel/slab/sighand_cache/alloc_calls": Function not implemented (38)

I'm stuck...

By: Reinhard Schu

Add the following to the rsync command:   --exclude /sys

later on server2:  mkdir /vz/private/211/sys