Ask Your Question
2

How to import a VMWare VM with multiple drives?

asked 2013-09-24 11:07:40 -0600

rz2p gravatar image

updated 2013-09-24 11:24:52 -0600

darragh-oreilly gravatar image

I have been importing VMs from my VMWare Workstation into my OpenStack, it works great. I am following this guide:

http://openstack.prov12n.com/convert-import-a-vmware-image-to-openstack-kvm/

But, what happens if my VM has 2 seperate drives? The command supports only 1 source drive. If OpenStack accepted OVF, I could try that but it does not seem to like OVF files.

Is this not possible? Thanks for any help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-09-24 14:53:51 -0600

rz2p gravatar image

updated 2013-09-24 15:00:56 -0600

I was able to solve this with a huge hack-around. This is how it's done:

  • Consolidate all your split disks into one.

vmware-vdiskmanager -r Virt-disk1.vmdk -t 0 Virt-disk1.vmdk

vmware-vdiskmanager -r Virt-disk2.vmdk -t 0 Virt-disk2.vmdk

Disk 1 contains the OS(/root, /etc), Disk2 contains my larger partiition for /opt, /var folders. Disk 2 has my programs and applications.

Copy the 2 VMDK files to OpenStack via SCP.

  • Convert them to qemu:

qemu-image convert Virt-disk1.vmdk -O qcow2 Virt-disk1.qemu

qemu-image convert Virt-disk2.vmdk -O qcow2 Virt-disk2.qemu

  • Upload them to glance as seperate images(yeah this makes no sense, but keep reading):

glance image-create --name "Drive1" --disk-format=qcow2 --is-public=true --container-format=bare --file Virt-disk1.qemu

glance image-create --name "Drive2" --disk-format=qcow2 --is-public=true --container-format=bare --file Virt-disk2.qemu

  • Launch one of EACH instance through OpenStack. Take note of each of the instance IDs( i.e. 26a10821-6ecf-4ba5-96e3-79d398f3d2e3 )

Because one of the instances are loading only Drive 2, it will try and PXE boot..But that is fine..There is no bootable OS, only data!

The Drive 1 will boot into the OS, but complain about missing a hard disk, continue!

  • SSH into your openstack server and copy the drive file from "Drive2" to "Drive1":

cd /etc/nova/instances/DRIVE 2 ID <-- yes, drive TWO.

vi libvirt.xml

Copy the section of it's to your clipboard, for example:

<disk type="file" device="disk">
      <driver name="qemu" type="qcow2" cache="none"/>
      <source file="/opt/stack/data/nova/instances/44454c4c-3600-105a-8043-cac04f5a4431/disk"/>
      <target bus="virtio" dev="vda"/>
    </disk>>

and PASTE it into the XML of Drive 1:

cd /etc/nova/instances/DRIVE 1 ID <-- drive ONE.

vi libvirt.xml

So your XML should contain two drive locations now:

<disk type="file" device="disk">
  <driver name="qemu" type="qcow2" cache="none"/>
  <source file="/opt/stack/data/nova/instances/26a10821-6ecf-4ba5-96e3-79d398f3d2e3/disk"/>
  <target bus="virtio" dev="vda"/>
</disk>
<disk type="file" device="disk">
  <driver name="qemu" type="qcow2" cache="none"/>
  <source file="/opt/stack/data/nova/instances/44454c4c-3600-105a-8043-cac04f5a4431/disk"/>
  <target bus="virtio" dev="vdb"/>
</disk>
  1. Redefine the VM. If you don't, then the changes you made will be overwritten. note: the "XX" can be found by opening a console session on the Drive1 VM.

CD into the Drive 1 directory:

cd /opt/stack/data/nova/instances/26a10821-6ecf-4ba5-96e3-79d398f3d2e3
virsh destroy instance-000000xx (This will not delete your VM, it will simply power it off.)
virsh undefine instance-000000xx
virsh define libvirt.xml
virsh start instance-000000xx

To re-sync with OpenStack, Go to the instances page, and do a soft-reboot on the instance. It will come back online.

NOW. When the VM is created, you will have a /dev/vda and a /dev/vdb. you can mount /dev/vdb wherever and it will have the files that you left off with!

I really hope this helps someone!

edit flag offensive delete link more

Comments

does this solution work with havana release as well?? im trying to use this approach to load to qcow2 disk images. it seems after soft reboot the contents of libvirt.xml are rewritten to the original disk config..

soundar gravatar imagesoundar ( 2014-03-06 18:52:59 -0600 )edit

hi rz2p, when i relaunch my instance, i only see the vda not vdb. I will check file libvirt.xml and the file copy from Driver 2 is lost. How can i fix that?

leethaoqn gravatar imageleethaoqn ( 2014-09-22 04:44:55 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-09-24 11:07:40 -0600

Seen: 9,079 times

Last updated: Sep 24 '13