Page 1 of 1

createrawvmdk does not detect physical sector size

Posted: 29. Jun 2016, 05:06
by ShawnC
Hi Everyone,

It seems that createrawkvmdk does not correctly detect the physical sector size (4096) on a large advanced format disk and hence does not interpret the partition table correctly.

What seems to be happening is it expects to find the EBR of partition sdc5 at (sector 256 * 512/sect = abs disk offset 131072) instead of (sector 256 * 4096/sect = abs disk offset 1048576). Because the EBR does not live at 131072 there is no 0xAA55 signature and the createrawkvmdk and listpartitions function complain "VBoxManage: error: Logical partition without magic"

I think this is a bug but this is the first time I have tried accessing a raw partition from a VM. Am I missing something dumb? :)

Particulars follow...

Code: Select all

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

Host:	
Linux 3.13.0-52-generic #86-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

Reproduced in:
VirtualBox 4.3.36_Ubuntu r105129
VirtualBox 5.0.23r108337

The NTFS filesystem in sdc5 is healthy and accessible by both Linux and 
Windows 7 (dual boot).

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

xxx@xxx:~$ sudo fdisk /dev/sdc
Note: sector size is 4096 (not 512)

Command (m for help): p

Disk /dev/sdc: 4000.8 GB, 4000752599040 bytes
164 heads, 36 sectors/track, 165438 cylinders, total 976746240 sectors
Units = sectors of 1 * 4096 = 4096 bytes					<---- advanced format disk
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc4             256   976746239  3906983936    5  Extended
/dev/sdc5             512   268435967  1073741824    7  HPFS/NTFS/exFAT

Command (m for help): x

Expert command (m for help): p

Disk /dev/sdc: 164 heads, 36 sectors, 165438 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
 1 00   0   0    0   0   0    0          0          0 00
 2 00   0   0    0   0   0    0          0          0 00
 3 00   0   0    0   0   0    0          0          0 00
 4 00   4   5    0 163  36  383        256  976745984 05
 5 00   8   9    0  93  24  325        256  268435456 07

Expert command (m for help): 

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

xxx@xxx:xxx$ vboxmanage internalcommands listpartitions -rawdisk /dev/sdc
VBoxManage: error: Logical partition without magic				<---- same err with createrawvmdk
Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)

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

xxx@xxx:xxx$ strace vboxmanage internalcommands listpartitions -rawdisk /dev/sdc

... < snip > ...

lseek(8, 131072, SEEK_SET)              = 131072

                                          ^^^^^^     seek apparently wrong

read(8, "\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345\345"..., 512) = 512
write(2, "VBoxManage", 10VBoxManage)              = 10
write(2, ": ", 2: )                       = 2
write(2, "error: ", 7error: )                  = 7
write(2, "Logical partition without magic", 31Logical partition without magic) = 31

... < snip > ...

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

xxx@xxx:xxx$ hexedit -s /dev/sdc

	... ( 256 * 512 = 131072 = 0x20000 ) is dead space:

00020000   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020010   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020020   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020030   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020040   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020050   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020060   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020070   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020080   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020090   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000200A0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000200B0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000200C0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000200D0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000200E0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000200F0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020100   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020110   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020120   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020130   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020140   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020150   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020160   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020170   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020180   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
00020190   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000201A0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000201B0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000201C0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000201D0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000201E0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................
000201F0   E5 E5 E5 E5 E5 E5 E5 E5  E5 E5 E5 E5 E5 E5 E5 E5  ................  

                                                      ^^^^^  No 55 AA magic here!

	... ( 256 * 4096 = 1048576  = 0x100000 ) where the EBR really lives:

00100000   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100010   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100020   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100030   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100040   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100050   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100060   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100070   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100080   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100090   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001000A0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001000B0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001000C0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001000D0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001000E0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001000F0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100100   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100110   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100120   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100130   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100140   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100150   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100160   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100170   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100180   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
00100190   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001001A0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001001B0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 08  ................
001001C0   09 00 07 5D 58 45 00 01  00 00 00 00 00 10 00 00  ...]XE..........
001001D0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001001E0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
001001F0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 AA  ..............U.

	... ( 512 * 4096 = 2097152  = 0x200000 ) the partition starts:

00200000   EB 52 90 4E 54 46 53 20  20 20 20 00 10 01 00 00  .R.NTFS    .....
00200010   00 00 00 00 00 F8 00 00  3F 00 FF 00 00 02 00 00  ........?.......
00200020   00 00 00 00 80 00 80 00  FF FF FF 0F 00 00 00 00  ................
00200030   04 00 00 00 00 00 00 00  FF FF FF 07 00 00 00 00  ................
00200040   01 00 00 00 01 00 00 00  3A 69 74 38 07 0D C6 26  ........:it8...&
00200050   00 00 00 00 FA 33 C0 8E  D0 BC 00 7C FB 68 C0 07  .....3.....|.h..
00200060   1F 1E 68 66 00 CB 88 16  0E 00 66 81 3E 03 00 4E  ..hf......f.>..N
00200070   54 46 53 75 15 B4 41 BB  AA 55 CD 13 72 0C 81 FB  TFSu..A..U..r...
00200080   55 AA 75 06 F7 C1 01 00  75 03 E9 D2 00 1E 83 EC  U.u.....u.......
00200090   18 68 1A 00 B4 48 8A 16  0E 00 8B F4 16 1F CD 13  .h...H..........
002000A0   9F 83 C4 18 9E 58 1F 72  E1 3B 06 0B 00 75 DB A3  .....X.r.;...u..
002000B0   0F 00 C1 2E 0F 00 04 1E  5A 33 DB B9 00 20 2B C8  ........Z3... +.
002000C0   66 FF 06 11 00 03 16 0F  00 8E C2 FF 06 16 00 E8  f...............
002000D0   40 00 2B C8 77 EF B8 00  BB CD 1A 66 23 C0 75 2D  @.+.w......f#.u-
002000E0   66 81 FB 54 43 50 41 75  24 81 F9 02 01 72 1E 16  f..TCPAu$....r..
002000F0   68 07 BB 16 68 70 0E 16  68 09 00 66 53 66 53 66  h...hp..h..fSfSf
00200100   55 16 16 16 68 B8 01 66  61 0E 07 CD 1A E9 6A 01  U...h..fa.....j.
00200110   90 90 66 60 1E 06 66 A1  11 00 66 03 06 1C 00 1E  ..f`..f...f.....
00200120   66 68 00 00 00 00 66 50  06 53 68 01 00 68 10 00  fh....fP.Sh..h..
00200130   B4 42 8A 16 0E 00 16 1F  8B F4 CD 13 66 59 5B 5A  .B..........fY[Z
00200140   66 59 66 59 1F 0F 82 16  00 66 FF 06 11 00 03 16  fYfY.....f......
00200150   0F 00 8E C2 FF 0E 16 00  75 BC 07 1F 66 61 C3 A0  ........u...fa..
00200160   F8 01 E8 08 00 A0 FB 01  E8 02 00 EB FE B4 01 8B  ................
00200170   F0 AC 3C 00 74 09 B4 0E  BB 07 00 CD 10 EB F2 C3  ..<.t...........
00200180   0D 0A 41 20 64 69 73 6B  20 72 65 61 64 20 65 72  ..A disk read er
00200190   72 6F 72 20 6F 63 63 75  72 72 65 64 00 0D 0A 42  ror occurred...B
002001A0   4F 4F 54 4D 47 52 20 69  73 20 6D 69 73 73 69 6E  OOTMGR is missin
002001B0   67 00 0D 0A 42 4F 4F 54  4D 47 52 20 69 73 20 63  g...BOOTMGR is c
002001C0   6F 6D 70 72 65 73 73 65  64 00 0D 0A 50 72 65 73  ompressed...Pres
002001D0   73 20 43 74 72 6C 2B 41  6C 74 2B 44 65 6C 20 74  s Ctrl+Alt+Del t
002001E0   6F 20 72 65 73 74 61 72  74 0D 0A 00 00 00 00 00  o restart.......
002001F0   00 00 00 00 00 00 00 00  80 9D B2 CA 00 00 55 AA  ..............U.

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