[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using qemu-img to convert vhd to raw, wrong size

From: Gerhard Gonter
Subject: using qemu-img to convert vhd to raw, wrong size
Date: Fri, 12 Jun 2020 17:14:58 +0200

  I received a disk image, originating from a Citrix VM, which I want
to convert into raw format, so that I can mount it as a loopback
device.  Unfortunately, the resulting raw file is smaller than the
space needed to hold the disk image.  The raw image was created like

  qemu-img convert -p UUID.vhd -S 0 -O raw vmname_3.raw

I then inspected the vhd image using an interesting tool I found on
GitHub [1] called "go-vhd".  This is a part of it's output:

--- 8< ---
VHD footer
Original size:           0x0000001900000000 ( 107374182400 bytes )
Current size:            0x0000001900000000 ( 107374182400 bytes )
Disk geometry:           0xc8c810ff (c: 51400, h: 16, s: 255)
(107372544000 bytes)
--- >8 ---

First, I wonder why "Original size" and the size derived from the disk
geometry are different.  The raw image produced by qemu-img reflects
the disk geometry and has exactly 107372544000 bytes.  However, the
raw image is supposed to have 107374182400. fdisk complains about
missing sectors, when I use that raw file.  After inflating the raw
image to 107374182400 bytes using truncate, fdisk does not complain
any more, but apparently I lose data which is located near the end of
the full disk image on the original VM.

Is there a way to tell qemu-img to write the raw image with the size
given as "Original size" or can I supply a different geometry instead?
 Using 51404 cylinders should do the trick, I guess.

I understand, the tool that generated the vhd from the Citrix VM in
the first place seems to be the source of the problem.  Do you know of
a way to fix that problem at the source or can you suggest another way
around that problem?

* [1] https://github.com/rubiojr/go-vhd

regards, Gerhard Gonter

reply via email to

[Prev in Thread] Current Thread [Next in Thread]