Search code examples
windowscommand-lineusbdd

Write partial data from MBR.bin to a sector in USB


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?


Solution

  • 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