Problem

We need to migrate some OpenVZ VPS files to VMware image. The challenge is that OpenVZ has its files as plain files in the file system while VMware supports only different types of images.

Analysis

We could not use the vServer Converter – because it supports only certain Linux distributions (RedHat, Ubuntu, Suse).

Solution

This is what we did:

1. Create a file with dd:

# dd if=/dev/zero of=/tmp/commius.img bs=1024 count=5120000

This creates an 5GB empty image file (filled with zeros). Further we need to create a file system and copy files into it.

2. Create file system inside of this file:

# /sbin/mke2fs /tmp/YOURIMAGE.img
mke2fs 1.39 (29-May-2006)
/tmp/commius.img is not a block special device.
Proceed anyway? (y,n) y

3. Mount it:

# mount -o loop /tmp/YOURIMAGE.img /mnt/tmp

4. Copy all files into the image:

# cp -a /vz/private/110/* /mnt/tmp

5. Before moving the file anywhere, we can compress it:

# gzip -9 /tmp/initrd

6. Use some tool to convert .img to .vhd (Virtual Hard Drive) or native VMWare format.

#

Resources

  1. http://www.linuxforums.org/forum/linux-newbie/3196-how-can-i-create-bootable-img-2.html
  2. http://4sysops.com/archives/p2v-for-vmware-six-ways-to-convert-physical-to-virtual/
  3. http://www.eggheadcafe.com/software/aspnet/29197126/how-to-convert-img-hard-d.aspx
  4. http://en.wikipedia.org/wiki/Dd_%28Unix%29
  5. http://www.ffnn.nl/pages/articles/linux/vmware-player-image-creation.php
  6. http://communities.vmware.com/thread/134877
  7. http://communities.vmware.com/thread/193272
Converting files to image (OpenVZ to VMWare)

Leave a Reply

Your email address will not be published.