I am talking about disk signatures in context of the MBR. The area from 440 to 444 bytes.

Let's say I got a bootable raw image (bootable in a virtual machine).

How can I set the disk signature to a fixed (non-random) value while keeping the raw image bootable? How to automate (script) that?

(If you are wondering if that is useful and for what... It is useful in context of verifiable builds.)

  • reading wikipedia, doesn't the disk signature start at byte 441, so the 441st byte? – Thorsten Staerk Jan 30 '14 at 6:48
  • You tell me. ;-) – adrelanos Jan 30 '14 at 16:53
  • lol ok I was a bit annoyed by myself and not believing I had done this old mistake again. It is. They start counting with 0. – Thorsten Staerk Jan 30 '14 at 20:48

Take your image, extract the first sector:

dd if=image of=mbr.dat bs=512 count=1

write "AAAAA" to position 440-444 and do not truncate the file:

echo -en "\x41\x41\x41\x41\x41" | dd of=mbr.dat conv=notrunc seek=440 bs=1

Use a hexeditor like okteta to verify that it did what you wanted. Then write it back:

dd if=mbr.dat of=image conv=notrunc

See my wikiblog http://www.linuxintro.org/wiki/dd

  • Will it still be bootable? Can "modify dump.dat" be automated(scripted)? – adrelanos Jan 29 '14 at 16:21
  • yes using the command base64, more to come – Thorsten Staerk Jan 29 '14 at 16:32
  • You can use xxd -r to automate hex edits. For example echo "A: 00" | xxd -r - test.img writes 0x00 to position 0xA in test.img. – Martin von Wittich Jan 29 '14 at 16:57
  • completely edited it, now I am using dd's seek function to get to position 440 – Thorsten Staerk Jan 30 '14 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.