public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* Using qemu-img to directly convert physical disk to KVM image
@ 2010-11-08 22:48 Emmanuel Noobadmin
  2010-11-08 23:27 ` Michael Tokarev
  0 siblings, 1 reply; 5+ messages in thread
From: Emmanuel Noobadmin @ 2010-11-08 22:48 UTC (permalink / raw)
  To: kvm

I'm trying to convert a physical Windows XP machine into a KVM guest.
All the guides so far mentions using dd to create a flat image file,
then using qemu-img to convert that to qcow2. Since I've been making
mistake here and there, retrying the process several times (initially
converting each logical partition into an image), the question struck
me: is there any reason why I cannot do something like this
qemu-img convert -f /dev/sdc -O qcow2 /images/winxp.qcow instead of
having to do it in two passes which literally take hours each.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using qemu-img to directly convert physical disk to KVM image
  2010-11-08 22:48 Using qemu-img to directly convert physical disk to KVM image Emmanuel Noobadmin
@ 2010-11-08 23:27 ` Michael Tokarev
  2010-11-09  2:54   ` Emmanuel Noobadmin
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2010-11-08 23:27 UTC (permalink / raw)
  To: Emmanuel Noobadmin; +Cc: kvm

09.11.2010 01:48, Emmanuel Noobadmin wrote:
> I'm trying to convert a physical Windows XP machine into a KVM guest.
> All the guides so far mentions using dd to create a flat image file,
> then using qemu-img to convert that to qcow2. Since I've been making
> mistake here and there, retrying the process several times (initially
> converting each logical partition into an image), the question struck
> me: is there any reason why I cannot do something like this
> qemu-img convert -f /dev/sdc -O qcow2 /images/winxp.qcow instead of
> having to do it in two passes which literally take hours each.

This is exactly the way to do it - converting the physical disk directly
to a qcow (or whatever format) file using qemu-img.  I've no idea why
all the guide writers are so confused.

The only problem with your exact version is that you've extra -f
argument - it expects a parameter, the input image type, which is
raw, so either use -f raw, or remove -f.

/mjt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using qemu-img to directly convert physical disk to KVM image
  2010-11-08 23:27 ` Michael Tokarev
@ 2010-11-09  2:54   ` Emmanuel Noobadmin
  2010-11-09  7:53     ` Michael Tokarev
  0 siblings, 1 reply; 5+ messages in thread
From: Emmanuel Noobadmin @ 2010-11-09  2:54 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: kvm

Thanks for the confirmation and just for the benefit of anybody else
who subsequently searches for <keywords> KVM QEMU convert physical
drive virtual machine image </keywords>, yes it works :)

On 11/9/10, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 09.11.2010 01:48, Emmanuel Noobadmin wrote:
>> I'm trying to convert a physical Windows XP machine into a KVM guest.
>> All the guides so far mentions using dd to create a flat image file,
>> then using qemu-img to convert that to qcow2. Since I've been making
>> mistake here and there, retrying the process several times (initially
>> converting each logical partition into an image), the question struck
>> me: is there any reason why I cannot do something like this
>> qemu-img convert -f /dev/sdc -O qcow2 /images/winxp.qcow instead of
>> having to do it in two passes which literally take hours each.
>
> This is exactly the way to do it - converting the physical disk directly
> to a qcow (or whatever format) file using qemu-img.  I've no idea why
> all the guide writers are so confused.
>
> The only problem with your exact version is that you've extra -f
> argument - it expects a parameter, the input image type, which is
> raw, so either use -f raw, or remove -f.
>
> /mjt
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using qemu-img to directly convert physical disk to KVM image
  2010-11-09  2:54   ` Emmanuel Noobadmin
@ 2010-11-09  7:53     ` Michael Tokarev
  2010-11-09 16:22       ` Emmanuel Noobadmin
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2010-11-09  7:53 UTC (permalink / raw)
  To: Emmanuel Noobadmin; +Cc: kvm

09.11.2010 05:54, Emmanuel Noobadmin wrote:
> Thanks for the confirmation and just for the benefit of anybody else
> who subsequently searches for <keywords> KVM QEMU convert physical
> drive virtual machine image </keywords>, yes it works :)

Heh.  Well, it is not something unexpected really.  Just a few more
comments below...

> On 11/9/10, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> 09.11.2010 01:48, Emmanuel Noobadmin wrote:
>>> I'm trying to convert a physical Windows XP machine into a KVM guest.
>>> All the guides so far mentions using dd to create a flat image file,
>>> then using qemu-img to convert that to qcow2. Since I've been making
>>> mistake here and there, retrying the process several times (initially
>>> converting each logical partition into an image), the question struck
>>> me: is there any reason why I cannot do something like this
>>> qemu-img convert -f /dev/sdc -O qcow2 /images/winxp.qcow instead of
>>> having to do it in two passes which literally take hours each.

You mentioned several kinds of storage.  The format of (virtual) drive
can be raw or qcow2, or others supported by qemu.  The location of the
data can be in a file on a filesystem, or it can be a physical device
(/dev/sdc), or a lvm volume, or a partition, or an iscsi lun, or any
other block device.  Either reasonable combination of the two can be
used.

In this case, running your guest off /dev/sda directly will work too.
Moreover, you most likely does not want to convert it to a qcow2 format,
due to various small and large issues with it - the "flat image file"
created with dd, or a raw format created by `qemu-img -O raw' (which
is almost the same but with zero blocks skipped) will most likely work
better (read: faster and more reliable).

/mjt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Using qemu-img to directly convert physical disk to KVM image
  2010-11-09  7:53     ` Michael Tokarev
@ 2010-11-09 16:22       ` Emmanuel Noobadmin
  0 siblings, 0 replies; 5+ messages in thread
From: Emmanuel Noobadmin @ 2010-11-09 16:22 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: kvm

Just a bit more info from my unfortunate experience. I took about 20
hours to get the original WinXP machine virtualized including an
unfortunate bug?lock condition? That required a re-install after I
spent time doing an image.

Also initially I made the mistake of making an image of every
partition instead of cloning the entire physical drive. So that
obviously didn't work. When I realized my mistake, I thought since it
was possible to attach a physical drive to a guest, maybe I could run
the guest directly off the physical drive (the original was a fakeraid
1 so I had a backup copy in any case).

But for some reason it didn't work.

That was about the time I asked about the direct method. But the
resulting qcow2 didn't work in the end, I thought it did and happily
post my last update. However, the OS never managed to complete
booting, for some reason the guest took up 25% load and stay stuck.

I was running out of time, so apologies to the KVM folks, I took the
easy way out again (Xen didn't work for me either a yr ago).
Downloaded VM Player, qemu-img to a vmdk and although there was an
error message about invalid boot.ini, the XP guest works.

Despite the possibility of losing yet another day, I'll still give KVM
a try the next time I have to virtualize a machine.


On 11/9/10, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 09.11.2010 05:54, Emmanuel Noobadmin wrote:
>> Thanks for the confirmation and just for the benefit of anybody else
>> who subsequently searches for <keywords> KVM QEMU convert physical
>> drive virtual machine image </keywords>, yes it works :)
>
> Heh.  Well, it is not something unexpected really.  Just a few more
> comments below...
>
>> On 11/9/10, Michael Tokarev <mjt@tls.msk.ru> wrote:
>>> 09.11.2010 01:48, Emmanuel Noobadmin wrote:
>>>> I'm trying to convert a physical Windows XP machine into a KVM guest.
>>>> All the guides so far mentions using dd to create a flat image file,
>>>> then using qemu-img to convert that to qcow2. Since I've been making
>>>> mistake here and there, retrying the process several times (initially
>>>> converting each logical partition into an image), the question struck
>>>> me: is there any reason why I cannot do something like this
>>>> qemu-img convert -f /dev/sdc -O qcow2 /images/winxp.qcow instead of
>>>> having to do it in two passes which literally take hours each.
>
> You mentioned several kinds of storage.  The format of (virtual) drive
> can be raw or qcow2, or others supported by qemu.  The location of the
> data can be in a file on a filesystem, or it can be a physical device
> (/dev/sdc), or a lvm volume, or a partition, or an iscsi lun, or any
> other block device.  Either reasonable combination of the two can be
> used.
>
> In this case, running your guest off /dev/sda directly will work too.
> Moreover, you most likely does not want to convert it to a qcow2 format,
> due to various small and large issues with it - the "flat image file"
> created with dd, or a raw format created by `qemu-img -O raw' (which
> is almost the same but with zero blocks skipped) will most likely work
> better (read: faster and more reliable).
>
> /mjt
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-09 16:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-08 22:48 Using qemu-img to directly convert physical disk to KVM image Emmanuel Noobadmin
2010-11-08 23:27 ` Michael Tokarev
2010-11-09  2:54   ` Emmanuel Noobadmin
2010-11-09  7:53     ` Michael Tokarev
2010-11-09 16:22       ` Emmanuel Noobadmin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox