0

DD is a tool for linux which can Write partial data from MBR.bin to a sector in USB (instead of writing a whole sector). Now I need to do such thing in windows. There is a DD for windows, but it seems it will write a whole sector!

I need to write first 440 bytes of a mbr file to a usb stick. the code in linux is:

dd if=mbr.bin of=/dev/sd<X> bs=440 count=1

and in windows it will be:

dd bs=440 count=1 if=mbr.bin of=\\.\<x>:

where x is the volume letter. But in windows it will cause USB to be corrupted and usb need to be formatted. It seems it writes the whole data. How can I solve this problem?

Inside Man
  • 4,194
  • 12
  • 59
  • 119

2 Answers2

2

Copy a complete block!

e.g. for a 512 byte blocksize (512-440=72)

copy mbr.bin mbr.full
dd bs=1 if=\\.\<x>: skip=440 seek=440 of=mbr.full count=72
dd bs=512 if=mbr.full of=\\.\<x>: count=1
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
  • no it is not working :( Again it will make USB Corrupted and it must be formatted! – Inside Man May 11 '15 at 08:15
  • I need to write first 440 bytes of mbr.bin into sector 0 of USB derive. Just Executed your script and it worked normally, but it seems is writing the whole sector in USB and it will make USB corrupted. – Inside Man May 11 '15 at 08:21
  • 1
    Ofcourse it will write the whole sector: The first 440 bytes from mbr.bin, and the rest from the existing data, i.e. unchanged. For this to work, you must use the correct block size. – Eugen Rieck May 11 '15 at 08:22
  • Can you guide how to get correct block size and make this script to work? – Inside Man May 11 '15 at 08:24
  • 1
    Yes: You use google to find out how to determine the block size of your USB, or you ask another question here. With the result, you come back to my answer. – Eugen Rieck May 11 '15 at 08:25
  • 1
    What file system is your USB? Use http://stackoverflow.com/questions/9465451/how-can-i-determine-the-sector-size-in-windows if it is NTFS. – Eugen Rieck May 11 '15 at 08:25
  • Block Size of USB is 512, as it is used in the script. – Inside Man May 11 '15 at 08:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/77491/discussion-between-stranger-and-eugen-rieck). – Inside Man May 11 '15 at 08:29
2

Are you sure you pass the parameters correctly? Maybe the win version expects it to be /bs=440. Just a guess. Can't you anyway just truncate the file to 440 bytes?

fassl
  • 724
  • 7
  • 9