Convert physical drive to virtual drive


Dedi Addict
Here's the situation, I have a physical drive that contains about 200 gigs of data that I need to convert to a virtual drive to mount on either a kvm or openvz machine. How would you go about doing this? I really need to keep the downtime to a minimum.

Thanks ahead of time.


Content Contributer
dd your hard drive to an image file:

dd if=/dev/hda1 of=/var/lib/libvirt/hdd/serverdisk.img

Mount in into your vps. Done.


Not to be taken seriously, ever!
Depends on virtualization. For vmware I would use vmware converter


New Member
Why not pass physical disk directly to the kvm and call it good? Why does it need to be converted at all?
Assuming libvirt, add a block to your vm's container XML (or use virt-manager, or whatever you use to add this block for you)

    <disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/disk'/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
If you're passing raw arguments to KVM, it'd look like so:

-drive file=/dev/disk,if=none,id=drive-virtio-disk1,format=raw,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk1,id=virtio-disk1
Same with OVZ, mount /dev/disk /somewhere/in/ovz/container/prebind/root

Change /dev/disk to the appropriate device file.
Last edited by a moderator:


Dedi Addict
@acd - I couldn't do that because I was moving data from a physical server to a new virtual server. I'm moving a lot of my physical servers to virtual servers.


New Member
Makes sense to me.

In that case, an openvz image is basically a tarball of the root directory without /boot or /lib/modules.

Making one is pretty much as simple as 

cd /mounted/disk/path ; tar zcpSf /openvz-img.tar.gz --numeric-owner -X .
Worst case scenario, you rsync the data from the existing server to your virtual one.