Jump to content











Photo
- - - - -

How to write Syslinux gptmbr.bin (440 bytes) into MBR sector of GPT disk using dd.exe ?

gptmbr.bin dd.exe syslinux

  • Please log in to reply
10 replies to this topic

#1 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 445 posts
  •  
    India

Posted A week ago

in linux, we use

https://wiki.gentoo....iki/Syslinux/en

dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sda

http://www.lightofda...cgi/BIOSBootGPT

dd if=/usr/share/syslinux/gptmbr.bin of=/dev/sda bs=440 count=1

in Windows, I tried following equivalent dd.exe commands to write gptmbr.bin to mbr sector of GPT Disk .

dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3 bs=440 count=1
dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3 bs=440 count=1 conv=notrunc

But both gives following errors ??

C:\Users\DEv\Desktop\AIO>dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3 bs=440 count=1
rawwrite dd for windows version 0.6beta3.
Written by John Newbigin <jn@it.swin.edu.au>
This program is covered by terms of the GPL Version 2.

Error writing file: 87 The parameter is incorrect
1+0 records in
0+0 records out

and 

C:\Users\DEv\Desktop\AIO>dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3 bs=440 count=1 conv=notrunc
rawwrite dd for windows version 0.6beta3.
Written by John Newbigin <jn@it.swin.edu.au>
This program is covered by terms of the GPL Version 2.

notrunc
Error writing file: 87 The parameter is incorrect
1+0 records in
0+0 records out

Where I am doing mistake ? Does dd.exe not support bs=440 ?

Should I first convert 440 bytes gptmbr.bin to 512 bytes gptmbr.bin if possible ?

Does dsfi.exe and dsfo.exe support writing of 440 bytes gptmbr.bin to mbr sector of GPT disk ?

 

http://reboot.pro/to...e-9#entry193659

 

How Wonko [mkhidGPT001.zip]/GPTMBR.mbr is different from syslinux gptmbr.bin ?

 

Please help.... 



#2 misty

misty

    Silver Member

  • Developer
  • 916 posts
  •  
    United Kingdom

Posted A week ago

Do you need to include a blocksize in your command? Wouldn't just writing the file result in it being written to the first 440 bytes of the first sector of disk 3 anyway?

Maybe try -
dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3


#3 misty

misty

    Silver Member

  • Developer
  • 916 posts
  •  
    United Kingdom

Posted A week ago

BTW, writing to the first 440 bytes of sector 0 will leave the partition table (and if memory serves also any disk signature) intact.

:cheers:

Misty

#4 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 445 posts
  •  
    India

Posted A week ago

Maybe try -

dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3
C:\Users\DEv\Desktop\AIO>dd.exe if="D:\gptmbr.bin" of=\\.\PhysicalDrive3
rawwrite dd for windows version 0.6beta3.
Written by John Newbigin <jn@it.swin.edu.au>
This program is covered by terms of the GPL Version 2.

Error reading file: 87 The parameter is incorrect
0+1 records in
0+1 records out


#5 misty

misty

    Silver Member

  • Developer
  • 916 posts
  •  
    United Kingdom

Posted A week ago

@devdevadev
Does \\.\PhysicalDrive3 exist?

Also try removing the quotes from "D:\gptmbr.bin" - I haven't used dd for windows in a while and can't remember if they are supported. They are not required in your case anyway, as the path does not have any spaces.

Misty

#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14389 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

It depends on a number of things. basically if you write to a block device you cannot write less than the block size of the target device with a number of programs AFAICR, cannot say about dd for windows, surel dsfo/dsfi behave like that.
 
BUT writing to the MBR (first sector of hard disk) may be also a different issue (access denied) on some OS/systems.
 
There is NO GPTMBR.mbr in mkhidGPT001.zip, there is a  is a HidGPT63.mbr, obviously different from the Syslinux gptmbr.bin (besides the different name, it is a half-@§§edly modified MBR code, though it is originlly by the same Author, Peter Anvin).
 
Now, why Wonko in mkhidGPT.cmd would extract the MBR (to a file 512 bytes in size), patch its first 432 bytes and then write the patched file to the MBR (as opposed to more simply and directly patch the MBR on disk)?
ECHO Writing the special MBR ...
IF NOT EXIST HidGPT63.mbr CALL :Missing HidGPT63.mbr&GOTO :EOF
IF EXIST GPTMBR.mbr DEL GPTMBR.mbr
dsfo \\.\Physicaldrive%PhysDN% 0 512 GPTMBR.mbr
dsfi GPTMBR.mbr 0 432 HidGPT63.mbr
dsfi \\.\Physicaldrive%PhysDN% 0 512 GPTMBR.mbr
GOTO :EOF

:duff:
Wonko
  • devdevadev likes this

#7 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 445 posts
  •  
    India

Posted A week ago

@devdevadev
Does \\.\PhysicalDrive3 exist?

Attached File  Screenshot (93).png   30.78KB   0 downloads

C:\Users\DEv\Desktop\AIO>dd.exe if=D:\gptmbr.bin of=\\.\PhysicalDrive3
rawwrite dd for windows version 0.6beta3.
Written by John Newbigin <jn@it.swin.edu.au>
This program is covered by terms of the GPL Version 2.

Error reading file: 87 The parameter is incorrect
0+1 records in
0+1 records out


#8 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 445 posts
  •  
    India

Posted A week ago

dsfo \\.\Physicaldrive3 0 512 GPTMBR.mbr
dsfi GPTMBR.mbr 0 440 gptmbr.bin
dsfi \\.\Physicaldrive3 0 512 GPTMBR.mbr

Will it do exactly the same process linux dd command do here



#9 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14389 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

Will it do exactly the same process linux dd command do here ?

No, but it will give exactly the same result :)  ( through doing a different process).

 

GIven that the dsfi won't write to a block device any number of bytes that is not a multiple of the block size, the temporary file "GPTMBR.mbr" 512 bytes in size, combining the data from (a copy of) the current MBR with the code from the Syslinux gptmbr.bin is needed, in order to be able to write a "whole" sector.

 

:duff:

Wonko


  • devdevadev likes this

#10 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 445 posts
  •  
    India

Posted A week ago

http://reboot.pro/to...pe/#entry204816

http://reboot.pro/to...pe/#entry204831
 

Can we not use similar approach for syslinux gptmbr.bin as you described for grldr.mbr using dd.exe ?

dd.exe if=\\.\PhysicalDrive3 of=\GPTMBR.mbr count=1 --localwrt
dd.exe if=\gptmbr.bin of=\GPTMBR.mbr bs=440 count=1 --localwrt
dd.exe if=\GPTMBR.mbr of=\\.\PhysicalDrive3 count=1 --localwrt
dd.exe if=\\.\PhysicalDrive3 of=\GPTMBR.mbr bs=512 count=1
dd.exe if=\gptmbr.bin of=\gptmbr512.bin bs=512 count=1
dd.exe if=\GPTMBR.mbr of=\gptmbr512.bin bs=1 count=72 skip=440 seek=440
dd.exe if=\gptmbr512.bin of=\\.\PhysicalDrive3 bs=512 count=1


#11 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14389 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted A week ago

That (with --localwrt ) is a DIFFERENT program. it is the dd of the FAU , not the "dd for Windows" by John Newbigin you were using/mentioned earlier.

 

But of course the "interemediate file" approach can work as well :) , though I lost you with the "bs=512 count=16" :dubbio: if you are referencing this post:

http://reboot.pro/to...pe/#entry204831

it is about copying (and "installing") the whole "normal" grldr.mbr (which is actually 16 sectors) and BTW there is also a reference to yet another dd version, the Cygwin one where (at least with the 32 bit and on XP) the bs=440 count=1 worked just fine.

 

 

:duff:

Wonko







Also tagged with one or more of these keywords: gptmbr.bin, dd.exe, syslinux

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users