LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 01-03-2011, 05:07 AM   #1
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Rep: Reputation: 39
converting KVM virtual machines to VMware images


I am using KVM on Ubuntu Server 10.04. and Virtual Machines are running on it in LVM.
I have to migrate some of them to Vmware server.How can I achieve this.
I searched and came across some links but they all talked converting vmdk images to qcow or so.
In this case I have OS in LVM.

http://blog.bodhizazen.net/linux/con...irtualbox-vdi/

http://communities.vmware.com/thread/224712

but any of the above did not helped me.
Can some one suggest as where do I begin?

Last edited by tkmsr; 01-03-2011 at 06:44 AM.
 
Old 01-03-2011, 09:33 AM   #2
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,227

Rep: Reputation: 86
Very rudimentary, but working :

Launch you virtual machine, booting with the g4l (ghost for linux) iso.
Backup an image you save on network (plenty of tutos around).
Create a vmware machine (care of disk size, must be equal or higher than qemu), boot g4l on it and restore the image.

Be aware that if your image is windowze, you probably have to boot with install disk and repair the installation (in the "install on this partition" menu) after restoring it in vmware.
 
Old 01-05-2011, 03:06 AM   #3
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by Linux.tar.gz View Post
Very rudimentary, but working :

Launch you virtual machine, booting with the g4l (ghost for linux) iso.
Not possible I do not have access to rack to connect monitor or some switch to get the display on to a monitor.
Quote:
Originally Posted by Linux.tar.gz View Post
Backup an image you save on network (plenty of tutos around).
I have rsync backup of the LVMs.
Quote:
Originally Posted by Linux.tar.gz View Post
Create a vmware machine (care of disk size, must be equal or higher than qemu), boot g4l on it and restore the image.
Ok I get your point.
Quote:
Originally Posted by Linux.tar.gz View Post
Be aware that if your image is windowze, you probably have to boot with install disk and repair the installation (in the "install on this partition" menu) after restoring it in vmware.
Some one suggested to use the snapshot volume to do all this and as they suggested

Quote:
lvcreate -L592M -s -n myvolume /dev/myvg/myvolume_snapshot
qemu-img convert /dev/myvg/myvolume_snapshot -O vmdk myvolume.vmdk
I am having hard time here setting up the NFS my USB stick has got some problems so I am not able to do so currently.
 
Old 01-05-2011, 04:16 AM   #4
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,227

Rep: Reputation: 86
Indeed, you can work with raw data.
Heh, setting up NFS is not THAT hard... ;^)

Post your results, as it is an interesting and useful thread.
 
Old 01-05-2011, 04:19 AM   #5
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
I know NFS is a damn easy thing to do.
My problem about NFS I opened in another thread as I did not wanted to mix this thread with the other problem.
If you want to look that thread then http://www.linuxquestions.org/questi...volume-854301/
only when my NFS problem gets solved I will be able to proceed on this thread.
 
Old 01-06-2011, 09:54 AM   #6
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Ok since the NFS thing got resolved by your help.
Now updating my attempt to migrate KVM guests to Vmware server.
I found here
http://linhost.info/2009/04/vmware-c...-ubuntu-linux/
How ever in spite of the fact that converter for Linux is free I did not found it useful.

I tested it on two machines first I tried to install the converter on Ubuntu server(where the VMs are actually running) 10.04 64 bit (it badly failed).
God knows how people have succeeded in using it.

Second attempt was to install on a Ubuntu Desktop 10.04 64 bit.The installation went peacefully but the converter
failed to detect the Virtual Machine running on remote host (there is an option to give SSH credentials to vmware-client-converter).
So the converter even failed to work.
I will try to convert the LVM based VM in a qcow image and then convert that to vmdk will post the results as what happened.

Last edited by tkmsr; 01-06-2011 at 09:56 AM.
 
Old 01-06-2011, 10:43 AM   #7
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,227

Rep: Reputation: 86
I'm just asking myself if qemu-img can convert directly to vmdk...
 
Old 01-06-2011, 10:54 AM   #8
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,159

Rep: Reputation: 258Reputation: 258Reputation: 258
Hi

I never tried this, but maybe this converter will not mind that it's a virtual machine?

http://www.vmware.com/products/converter/
 
Old 01-06-2011, 11:12 AM   #9
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Guttorm in my post above the converter which I mentioned has failed is the same thing which you pointed out.

@Linux.tar.gz
qemu-img directly to vmdk (yes correct) I am away from that system I will try and post the results (it might take next week but I surely will update here )

Last edited by tkmsr; 01-06-2011 at 01:05 PM.
 
Old 01-07-2011, 01:02 AM   #10
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
I am a bit confused with qemu-img.
I was reading man page of qemu-img and what I understand is I need to first create a qcow image file which I need to populate and then convert that to a vmdk file.
Is that understanding correct.

What the situation is it is a production environment where I am having Guest OS running.These OS are in an LVM based setup.

Here is output of lvscan
Quote:
ACTIVE '/dev/abcd/lvm1' [100.00 GiB] inherit
ACTIVE '/dev/abcd/lvm2' [150.00 GiB] inherit
ACTIVE '/dev/abcd/lvm3' [50.00 GiB] inherit
ACTIVE '/dev/abcd/lvm4' [100.00 GiB] inherit
Now suppose /dev/abcd/lvm4 is what I would like this to be in its original format running on the server where it is.Can pause or shutdown for some time to take backup.

How ever I want one more image of the
Quote:
/dev/abcd/lvm4
which I would like to run on a vmware setup.
So I have two servers one where
Quote:
/dev/abcd/lvm4
is originally hosted and will keep running for production use where as another place
where vmware is running there would be different experiments on this vmdk file.

Show is the following way

Quote:
qemu-img convert -c -f raw -O vmdk /dev/abcd/lvm4 /backup/lvm4.img
the correct way to go or it will affect the lvm4 on which I apply it and mess with original lvm4.


how

Last edited by tkmsr; 01-07-2011 at 01:03 AM.
 
Old 01-07-2011, 08:17 AM   #11
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,227

Rep: Reputation: 86
So you better have to use :
find / -depth | cpio -pduv /newfolder

Adapt it to your needs, ie. :

find /where/is/mounted/dev/abcd/lvm4/ -depth | cpio -pduv /newfolder

I will create a cpio archive you can "unzip" on a hard drive, virtual or not.

But i still recommend my first suggestion too. You don't need a cd drive, as you boot the qemu with an .iso.

I have no idea if your qemu-img command will work as you wish, but it won't mess your original lvm, as it only reads it.
 
Old 01-07-2011, 08:53 AM   #12
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by Linux.tar.gz View Post
So you better have to use :
find / -depth | cpio -pduv /newfolder
Adapt it to your needs, ie. :
find /where/is/mounted/dev/abcd/lvm4/ -depth | cpio -pduv /newfolder
I will create a cpio archive you can "unzip" on a hard drive, virtual or not.
But i still recommend my first suggestion too. You don't need a cd drive, as you boot the qemu with an .iso.
I have no idea if your qemu-img command will work as you wish, but it won't mess your original lvm, as it only reads it.
Ok I do have the first suggestion you gave me in mind.How ever currently due to hardware constraints it is not possible to do the same.I have no access to a monitor to be able to boot and see the results.Hence I have to do every thing with ssh connection.
Right now this is what I just tried before I read your message
Code:
lvcreate -L5G -s -n myvolume /dev/myvg/myvolume_snapshot
qemu-img convert /dev/myvg/myvolume_snapshot -O vmdk myvolume.vmdk
It is a big LVM volume.So it is taking some time I have no idea as when it will complete but let me see what is the outcome of this work.I hope this should work.

Last edited by tkmsr; 01-07-2011 at 09:27 AM.
 
Old 01-07-2011, 10:25 AM   #13
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,227

Rep: Reputation: 86
You don't need a monitor when you have ssh ^^.
You can tunnel the X output of applications.
More easy, you can also start qemu with a vnc exported display.
 
Old 01-07-2011, 10:43 AM   #14
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by Linux.tar.gz View Post
You don't need a monitor when you have ssh ^^.
You can tunnel the X output of applications.
More easy, you can also start qemu with a vnc exported display.
Ok
in your above post
Quote:
Originally Posted by Linux.tar.gz View Post
Very rudimentary, but working :

Launch you virtual machine, booting with the g4l (ghost for linux) iso.
I am not clear doing this part on ssh.

Quote:
Originally Posted by Linux.tar.gz View Post
Backup an image you save on network (plenty of tutos around).
Create a vmware machine (care of disk size, must be equal or higher than qemu), boot g4l on it and restore the image.
The lvm size where the production machine is running is 100G so do I need to have a 100G size in the vmware machine which you say me to create.

Quote:
Originally Posted by Linux.tar.gz View Post
Be aware that if your image is windowze, you probably have to boot with install disk and repair the installation (in the "install on this partition" menu) after restoring it in vmware.
I am not clear on this part.

Results of my expermient

Code:
lvcreate -L5G -s -n myvolume /dev/myvg/myvolume_snapshot
qemu-img convert /dev/myvg/myvolume_snapshot -O vmdk myvolume.vmdk
Here I waited for 2 hours and I see a vmdk file which is 12 GB but still the second command is not complete and I see the file
further growing in size beyond 12GB.I have to go out of office so can not continue this command for a moment.So if you can tell what exactly is happening why even after a 12 GB of vmdk things did not stopped.


Also I have one more question I already have the rsync backups of the LVMs in some folders on a USB hard disk.The size of these folders is not more than 5GB or 6GB.Is it not possible to convert these to a format which I can use in vmware or some thing like that?

Last edited by tkmsr; 01-07-2011 at 10:49 AM.
 
Old 01-07-2011, 12:38 PM   #15
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,227

Rep: Reputation: 86
Launching qemu -vnc display[,option[,option[,...]]] will create a vnc output, so it's pretty easy to connect to it.
You also have to use -boot d -cdrom g4l.iso

I indeed highly recommend to have the same size, ie 100G.

The virtual chipsets of qemu are not necessary the same as the vmware. So, like on real hard drive, if you move a XP from a motherboard to another, you will probably get a BSOD. So you have to repair XP with the cd.

"lvcreate -L5G -s -n myvolume /dev/myvg/myvolume_snapshot
qemu-img convert /dev/myvg/myvolume_snapshot -O vmdk myvolume.vmdk"
Why are you creating an empty lvm, and converting it to .vmdk ?
You can create vmdk directly with qemu-img or vmware.

I have no idea why it oversized the 5G...

I doubt rsync preserves all files attributes. That's why i use cpio instead of a simple tar.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Host OS unable to connect to Guest OS (virtual machines) in VMware vikas027 Linux - Virtualization and Cloud 18 08-16-2012 09:15 AM
LXer: One way to migrate Xen virtual machines to KVM in Debian LXer Syndicated Linux News 0 11-19-2010 11:42 AM
[SOLVED] converting a windows xp VMware virtual host for use on VirtualBox carltm Linux - Virtualization and Cloud 4 12-07-2009 11:22 AM
Xen vs. VirtualBox vs. VMware. which is better for running several virtual machines? accend Linux - Server 3 05-06-2009 10:35 AM
Converting a Dual Boot Box and Network Into Virtual Machines Woodsman Slackware 2 04-18-2008 11:28 PM


All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration