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
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