VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Discussions related to using VirtualBox on Mac OS X hosts.
mjh75ca
Posts: 1
Joined: 2. Aug 2017, 17:15

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by mjh75ca »

I know this is an oldish thread. I just encountered the same issue:

Code: Select all

sudo VBoxManage internalcommands createrawvmdk -rawdisk /dev/disk0 -filename wind10raw.vmdk -partitions 1,4
results in:

Code: Select all

VBoxManage: error: Cannot read the partition information from '/dev/disk0'
VBoxManage: error: The raw disk vmdk file was not created
Host=10.12.6, Upgrade=No, Guest=Win10, VBox=5.1.26, Filevault=No, FileVaultBeforeBootcamp=No, Works = NO

Fresh install of Windows 10 in Bootcamp. Have upgraded MacOS as prompted by the system so it is now on 10.12.6 but started on 10.12.4 I believe it was. As far as I know Filevault was never turned on.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by socratis »

Yes, it's not a matter of FileVault as the discussion in the thread has proven. It's the "new installation of Windows 10" that's the problem. You did a new installation => you have the problem.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
jtkirk
Posts: 3
Joined: 18. Aug 2017, 16:04

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by jtkirk »

Nope, it doesn't appear to be Win10. I'm trying to run Fedora26 on my new 2017 macbook pro 15". Took 250G and created a plain old mac style journaled partition. I've never attempted to install windows 10 on this system. I'm getting the same error:

Code: Select all

bash-3.2$ sudo /Applications/VirtualBox.app/Contents/MacOS/VBoxManage internalcommands createrawvmdk -filename /Users/cdavis/vbox/raw_disk.vmdk -rawdisk /dev/disk0 -partitions 4
Password:
VBoxManage: error: Cannot read the partition information from '/dev/disk0'
VBoxManage: error: The raw disk vmdk file was not created
I went through all the same steps as everyone else - chmod and chown on disk0 and disk0s4

I was hoping to boot the VM using the Fedora installer USB, and format the partition ext4. Eventually, when the drivers are good enough, I was going to ditch the guest OS and just dual boot into Linux, just use VirtualBox as my temporary bridge for the meanwhile.
granada29
Volunteer
Posts: 704
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by granada29 »

jtkirk wrote:

Code: Select all

bash-3.2$ sudo /Applications/VirtualBox.app/Contents/MacOS/VBoxManage internalcommands createrawvmdk -filename /Users/cdavis/vbox/raw_disk.vmdk -rawdisk /dev/disk0 -partitions 4
I had this problem too and now seem to be having some success with the following sequence generated by VBoxRawdisk.

Code: Select all

08:42:36.898 /usr/sbin/chown bryan /dev/disk3*
08:42:36.928 Permissions modified for: disk3
08:42:36.930 /usr/sbin/chown bryan /dev/rdisk3*
08:42:36.951 Permissions modified for: rdisk3
08:42:39.663 Unmounting partitions - may take some time.
08:42:44.320 /usr/local/bin/VBoxManage storageattach Sierra-External --storagectl IDE --port 0 --device 0 --medium none
08:42:44.463 /usr/local/bin/VBoxManage closemedium disk /Volumes/VirtualMachines/VirtualBox/macOS/Sierra-External/Sierra-External.vmdk
08:42:44.510 /usr/local/bin/VBoxManage internalcommands createrawvmdk -filename /Volumes/VirtualMachines/VirtualBox/macOS/Sierra-External/Sierra-External.vmdk -rawdisk /dev/disk3 -partitions 1,2
08:42:44.586 RAW host disk access VMDK file /Volumes/VirtualMachines/VirtualBox/macOS/Sierra-External/Sierra-External.vmdk created successfully.
08:42:44.595 vmdk file created for device and added to VirtualBox media registry
[1] Make sure the VM has been configured with an IDE controller.
[2] Try toggling your setting for Host I/O caching in the VM settings.
[3] You may or may not need to include the EFI partition
[4] Make sure the partitions stay unmounted and unused.
quantor
Posts: 12
Joined: 8. Apr 2017, 10:20

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by quantor »

I had this problem too and now seem to be having some success with the following sequence generated by VBoxRawdisk.
I tried the sequence you proposed, but that doesn't work for me, I still get

Code: Select all

VBoxManage: error: Cannot read the partition information from '/dev/disk0'
VBoxManage: error: The raw disk vmdk file was not created
Do you get any output if you type in:

Code: Select all

/usr/local/bin/VBoxManage internalcommands listpartitions -rawdisk /dev/disk3
Harrumph
Posts: 2
Joined: 1. Nov 2017, 13:17

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by Harrumph »

My data on this issue:

Host=10.12.6, Upgrade=No, Guest=Win10 (fresh install), VBox=5.2.0, Works = NO

This is on a 2017 MBP, getting the same
VBoxManage: error: Cannot read the partition information from '/dev/disk0'
and running the listpartitions commands similarly yields no results as others reported above.
Kerrnel
Posts: 3
Joined: 1. Nov 2018, 01:12

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by Kerrnel »

Code: Select all

 $ VBoxManage --version
5.2.20r125813

 $ sudo gdisk /dev/disk0
GPT fdisk (gdisk) version 1.0.4

Warning: Devices opened with shared lock will not have their
partition table automatically reloaded!
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/disk0: 244276265 sectors, 931.8 GiB
Sector size (logical): 4096 bytes
Disk identifier (GUID): C254DA83-8A1B-4CCC-A786-A66302F7153B
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 244276259
Partitions will be aligned on 2-sector boundaries
Total free space is 630 sectors (2.5 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1               6           76805   300.0 MiB   EF00  EFI System Partition
   2           76806       207769087   792.3 GiB   AF0A  MacOS
   3       207769088       219804927   45.9 GiB    8300  Linux
   4       219805184       244157357   92.9 GiB    0700  Windows
   5       244157440       244275967   463.0 MiB   2700  Windows Recovery

 $ sudo dd if=/dev/disk0 of=/tmp/d0.img count=50
50+0 records in
50+0 records out
25600 bytes transferred in 0.001665 secs (15374310 bytes/sec)

 $ sudo "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"  internalcommands createrawvmdk -rawdisk "/tmp/d0.img" -filename "Greg.vmdk" -partitions 1,3
VBoxManage: error: Cannot read the partition information from '/tmp/d0.img'
VBoxManage: error: The raw disk vmdk file was not created

 $ sudo dtruss "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"  internalcommands createrawvmdk -rawdisk "/tmp/d0.img" -filename "Greg.vmdk" -partitions 1,3
SYSCALL(args)            = return
... snip ...
open("/tmp/d0.img\0", 0x1000000, 0x180)          = 6 0
fcntl(0x6, 0x1, 0x0)             = 1 0
fstat64(0x6, 0x7FFEE8184C18, 0x0)                = 0 0
fstat64(0x6, 0x7FFEE8180F88, 0x0)                = 0 0
lseek(0x6, 0x0, 0x0)             = 0 0
read(0x6, "\0", 0x200)           = 512 0
lseek(0x6, 0x200, 0x0)           = 512 0
read(0x6, "\0", 0x200)           = 512 0
write_nocancel(0x2, "VBoxManageamesStartWith\0", 0xA)            = 10 0
write_nocancel(0x2, ": neNumber\0", 0x2)                 = 2 0
write_nocancel(0x2, "error: tractID\0", 0x7)             = 7 0
write_nocancel(0x2, "Cannot read the partition information from '/tmp/d0.img'\0", 0x38)          = 56 0
... snp ...
Referencing: /browser/vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp at the source code repot, it seems that the only reason to return from "partRead()" around line 740 without an additional error message after the read we see happening with dtruss

Code: Select all

rc = RTFileReadAt(File, sector_size, &partitionTableHeader, sector_size, NULL);
is if the key values 0x55aa in sector 0 or "EFI PART" in sector 1 do not match or there is a read error (in my read through the code). I tried to build it on Mac so I could insert more messages for the other points of failure, but getting a build going on Mojave is non-trivial.

Code: Select all

 $ hexdump -C /tmp/d0.img |head -n 50
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 fe  |................|
000001c0  ff ff ee fe ff ff 01 00  00 00 28 5c 8f 0e 00 00  |..........(\....|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001000  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00001010  e5 2d 8f 4e 00 00 00 00  01 00 00 00 00 00 00 00  |.-.N............|
00001020  28 5c 8f 0e 00 00 00 00  06 00 00 00 00 00 00 00  |(\..............|
00001030  23 5c 8f 0e 00 00 00 00  83 da 54 c2 1b 8a cc 4c  |#\........T....L|
00001040  a7 86 a6 63 02 f7 15 3b  02 00 00 00 00 00 00 00  |...c...;........|
00001050  80 00 00 00 80 00 00 00  e2 dd 31 c0 00 00 00 00  |..........1.....|
00001060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002000  28 73 2a c1 1f f8 d2 11  ba 4b 00 a0 c9 3e c9 3b  |(s*......K...>.;|
00002010  2f 81 65 e4 c9 8c 37 48  99 79 d1 52 86 57 ff 58  |/.e...7H.y.R.W.X|
00002020  06 00 00 00 00 00 00 00  05 2c 01 00 00 00 00 00  |.........,......|
00002030  00 00 00 00 00 00 00 00  45 00 46 00 49 00 20 00  |........E.F.I. .|
00002040  53 00 79 00 73 00 74 00  65 00 6d 00 20 00 50 00  |S.y.s.t.e.m. .P.|
00002050  61 00 72 00 74 00 69 00  74 00 69 00 6f 00 6e 00  |a.r.t.i.t.i.o.n.|
00002060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002080  ef 57 34 7c 00 00 aa 11  aa 11 00 30 65 43 ec ac  |.W4|.......0eC..|
00002090  e7 78 6e 77 fc 5a 4e 4f  9a bd ee d2 55 d2 0f 02  |.xnw.ZNO....U...|
000020a0  06 2c 01 00 00 00 00 00  ff 4d 62 0c 00 00 00 00  |.,.......Mb.....|
000020b0  00 00 00 00 00 00 00 00  4d 00 61 00 63 00 4f 00  |........M.a.c.O.|
000020c0  53 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |S...............|
000020d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002100  af 3d c6 0f 83 84 72 47  8e 79 3d 69 d8 47 7d e4  |.=....rG.y=i.G}.|
00002110  eb 8a 22 c4 48 0d c7 45  a2 6c 8f 06 c2 ab d1 dc  |..".H..E.l......|
00002120  00 4e 62 0c 00 00 00 00  ff f4 19 0d 00 00 00 00  |.Nb.............|
00002130  00 00 00 00 00 00 00 00  4c 00 69 00 6e 00 75 00  |........L.i.n.u.|
00002140  78 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |x...............|
00002150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
I also booted into BootCamp and installed VB on Windows and tried the same command with the same failure.

The problem seems to be that the ID "EFI PART" is at offset 0x1000 on disk instead of the expected 0x200 in the code. I'm not sure if that is legal yet.

I think this is because the disk has 4K sector size recorded so that LBA1 starts at 0x1000 and not 0x0200.

This is hardcoded with

Code: Select all

uint32_t sector_size = 512;
The fix would be to support non-512 sector sizes (a couple of changes needed in partRead) and the title of this thread should be "Support 4Kn disks with 4K native sector size"

To test:

Code: Select all

dd if=/tmp/d0.img of=/tmp/d1.img bs=512 skip=8
dd if=/tmp/d0.img of=/tmp/dh.img bs=512 count=1
cat /tmp/dh.img /tmp/d1.img > /tmp/d2.img
 $ "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"  internalcommands createrawvmdk -rawdisk "/tmp/d2.img" -filename "Greg.vmdk" -partitions 1,3
Segmentation fault: 11
Whoops. Needs some work :P
Last edited by Kerrnel on 18. Dec 2018, 14:09, edited 1 time in total.
enf0rcer
Posts: 1
Joined: 12. Nov 2018, 10:21

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by enf0rcer »

Having the same problem on my MBP 2017:

MacOS: 10.14
FileVault: Yes
FileVault before Bootcamp: Yes,
Virtual Box: 5.2.22
Windows: 10

@Kerrnel, would it be possible to create something workable with your findings?
Kerrnel
Posts: 3
Joined: 1. Nov 2018, 01:12

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by Kerrnel »

I disassembled VBoxManage like

Code: Select all

otool -tvV /Applications/VirtualBox.app/Contents/MacOS/VBoxManage4k  > /tmp/vbm4k.dis
Then I searched for RTFileReadAt and found the offset of the code that had two load 0x0200 and a call right before "EFI BOOT" compare

Code: Select all

7500 000000010000af0b    movl    $0x1, (%r13)
   7501 000000010000af13    movl    $0xfffffffe, %r12d
   7502 000000010000af19    movzwl  -0x32(%rbp), %eax
   7503 000000010000af1d    cmpl    $0xaa55, %eax
   7504 000000010000af22    jne 0x10000b939
   7505 000000010000af28    leaq    -0x430(%rbp), %rdx
   7506 000000010000af2f    movl    $0x200, %esi
   7507 000000010000af34    movl    $0x200, %ecx
   7508 000000010000af39    xorl    %r8d, %r8d
   7509 000000010000af3c    movq    -0x438(%rbp), %rdi
   7510 000000010000af43    callq   0x1000bfbc0 ## symbol stub for: _RTFileReadAt
   7511 000000010000af48    movl    $0x1, %ebx
   7512 000000010000af4d    testl   %eax, %eax
   7513 000000010000af4f    js  0x10000b640
   7514 000000010000af55    leaq    0xd6300(%rip), %rsi ## literal pool for: "EFI PART"

Code: Select all

   7800 000000010000b45e    callq   0x1000bfc02 ## symbol stub for: _RTMemAllocZTag
   7801 000000010000b463    movq    %rax, %rbx
   7802 000000010000b466    testq   %rbx, %rbx
   7803 000000010000b469    je  0x10000b627
   7804 000000010000b46f    movl    $0x400, %esi
   7805 000000010000b474    xorl    %r8d, %r8d
   7806 000000010000b477    movq    -0x438(%rbp), %rdi
   7807 000000010000b47e    movq    %rbx, %rdx
   7808 000000010000b481    movq    %r12, %rcx
   7809 000000010000b484    callq   0x1000bfbc0 ## symbol stub for: _RTFileReadAt
   7810 000000010000b489    movl    %eax, %r12d
   7811 000000010000b48c    testl   %r12d, %r12d
   7812 000000010000b48f    js  0x10000b963
I then patched VBoxManage to RTFileReadAt with 0x1000 instead of 0x0200 and also down below patched the read of LBA2 at 0x0400 to read from 0x2000 ... and... whalla - it worked!

Code: Select all

 $ sudo "/Applications/VirtualBox.app/Contents/MacOS/VBoxManage4k"  internalcommands createrawvmdk -rawdisk "/dev/disk0" -filename "Greg.vmdk" -partitions 1,3
Password:
RAW host disk access VMDK file Greg.vmdk created successfully.
Hexedit the binary yourself and change 0x0200 to 0x1000 and 0x0400 to 0x2000 as noted above (the value loaded to %esi)... but

The .vmdk and -pt.vmdk file are incorrectly filled though - using the raw values from a 4K disk. I don't think this is safe.

The correct solution remains to update the source code to support 4kn disks.


- Greg
Harrumph
Posts: 2
Joined: 1. Nov 2017, 13:17

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by Harrumph »

Was this issue ever pursued further? Kerrnel seemed to be on to something here...

I checked the changelogs for VirtualBox 6.0.1 and above, but could not see any reference to this particular problem (I admit, I am not sure what I would even look for).

Also, I checked for bug tickets, but could not see that Kerrnel has posted one about this issue.

EDIT: however, I found the bug ticket which references the original topic of this thread: https://www.virtualbox.org/ticket/16705
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: VBoxManage internalcommands createrawvmdk error: Cannot read the partition info...

Post by socratis »

Since you're on OSX, you could give it a shot with the VBoxRawdisk utility. Haven't had a BootCamp for years so I can't test it. And AFAIK, neither had the author of that program, but you got nothing to lose. Feedback appreciated...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply