VMWare vmdk converted to raw image - Will Not Boot (Windows or Linux)

738 views
Skip to first unread message

joev...@gmail.com

unread,
Aug 14, 2018, 1:03:19 AM8/14/18
to qubes-users
I have to work with VMWare images often, so I would like them to be run in Qubes.
They gave me a Windows 10 and a Kali vmware virtual machines.
Many people, including myself, have tested these as working in VMWare Player. There isn't a problem with the source.

The vmx files only points to the images I am converting, so I don't think I am missing something there.

-----------------

$ file C-Drive.vmdk
C-Drive.vmdk: VMware4 disk image

$ qemu-img info C-Drive.vmdk
image: C-Drive.vmdk
file format: vmdk
virtual size: 100G (107374182400 bytes)
disk size: 13G
cluster_size: 65536
Format specific information:
cid: 1024382763
parent cid: 4294967295
create type: monolithicSparse
extents:
[0]:
virtual size: 107374182400
filename: C-Drive.vmdk
cluster size: 65536
format:

$ qemu-img convert -f vmdk C-Drive.vmdk -O raw Win10.raw

$ file Win10.raw
Win10.raw: DOS/MBR boot sector MS-MBR Windows 7 english at offset 0x163 "Invalid partition table" at offset 0x17b "Error loading operating system" at offset 0x19a "Missing operating system", disk signature 0x8d1c10fa; partition 1 : ID=0x7, active, start-CHS (0x0,32,33), end-CHS (0x3ff,254,63), startsector 2048, 209711104 sectors

$ qemu-img info Win10.raw
image: Win10.raw
file format: raw
virtual size: 100G (107374182400 bytes)
disk size: 12G

$ sudo fdisk -l Win10.raw
Disk Win10.raw: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x8d1c10fa

Device Boot Start End Sectors Size Id Type
Win10.raw1 * 2048 209713151 209711104 100G 7 HPFS/NTFS/exFAT

------------------

$ qvm-create --verbose Win10 --class StandaloneVM --property virt_mode=hvm --property kernel='' --property memory=4096 --property maxmem=4096 --label=red --root-copy-from Win10.raw

When I start the VM... it boots to the Windows "Diagnostics" menu, and any attempts to fix/repair fail.
I have tried booting this VM to a Windows 10 iso to see if it could repair it too, no luck.

==============================

The Kali VM is similar, in that it will not boot using this convert to raw method. It boots to the grub rescue menu.

The only difference between Kali and Windows VMware, is that Kali disk was split into a span of 8 vmdk's. But qemu-img does create a single raw image as expected.

$ qemu-img convert -f vmdk *.vmdk -O raw Kali.img

$ qemu-img info Kali.img
image: Kali.img
file format: raw
virtual size: 60G (64424509440 bytes)
disk size: 19G

$ file Kali.img
Kali.img: DOS/MBR boot sector; partition 1 : ID=0x82, active, start-CHS (0x3ff,254,63), end-CHS (0x3ff,254,63), startsector 123179008, 2648064 sectors

$ sudo fdisk -l Kali.img
Disk Kali.img: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xaaea4a6f

Device Boot Start End Sectors Size Id Type
Kali.img1 * 123179008 125827071 2648064 1.3G 82 Linux swap / Solaris

====================

I've tried qvm-start with hddisk and cdrom option. No luck there.
I've tried using VMWare's "ovftool" to package the vm, tar extract the single new vmdk, then convert to raw.
I've tried converting to qcow2.
And tried running "testdisk" to find and fix MBR and partition tables.

I can mount the images to view the file systems if I want. But somewhere in the conversion (qemu-img) or the VM creation (qvm-create ... root-copy-from), the MBR or partitioning gets screwed up and cannot boot. I need to boot and run these VMs.

But I am lost. It would seem straight forward, as everywhere I look on the internet, converting to raw is pretty easy and should work in Qubes 4.

Michael MENG

unread,
Aug 14, 2018, 1:41:58 AM8/14/18
to qubes-users
I did that before on win7 and qubes3.2, but i use qemu for windows to convert to raw, its smooth, just qwt i dont like it shown test mode.

awokd

unread,
Aug 15, 2018, 6:52:02 AM8/15/18
to joev...@gmail.com, qubes-users
On Tue, August 14, 2018 5:03 am, joev...@gmail.com wrote:

> $ qvm-create --verbose Win10 --class StandaloneVM --property
> virt_mode=hvm --property kernel='' --property memory=4096 --property
> maxmem=4096 --label=red --root-copy-from Win10.raw

How large is the root created when you use this method? Default is only
10GB, but both your images are much larger. Try manually creating the HVM
without the copy, resizing the root volume to match the raw size, then
"copy Win10.raw /dev/mapper/qubes_dom0-vm--Win10--root".

joev...@gmail.com

unread,
Aug 16, 2018, 3:19:03 PM8/16/18
to qubes-users

Yes. Thank you. That did it.

Set the system storage max size to greater than the filesytem size of the raw image.
dd if=Win10.raw of=/dev/mapper/qubes_dom0-vm--Win10--root

Now both boot.

I guess system storage should be a pref option in qvm-create, so we can still use --root-copy-from. Or, better yet, determine size automatically and prompt the user to accept the larger storage size.

Reply all
Reply to author
Forward
0 new messages