I have a flashing system for a tablet what got an internal SD card to be formatted on every flash. Basically, it writes an MBR file to it, instead of using a partitioning app (fdisk, or anything), and for that, I would need an app to create these MBR files. As I don't have all of the possible sizes of cards, I really need an app what could create partition layout MBRs for given sizes (4/8/16/32GB). Is there any solution?
migrated from stackoverflow.com Jul 31 '11 at 18:02
This question came from our site for professional and enthusiast programmers.
An MBR is not a file; it is a partition table format occupies the first 512 bytes of a volume. The 64 bytes from the 447th byte to the 510th byte describe the partitions. A description of the format's structure can be found on Wikipedia's article on this topic. An MBR partition table can define up to four partitions, and each one takes 16 bytes, totalling 64 bytes.
An MBR doesn't differ depending on volume size. If, however, you would like to create an MBR and define a partition spanning the whole volume, regardless of size, that is another question.
A clever way that you can make MBRs for the different sizes for later use is to make a file of the volume size, run
MBR for one partition spanning the entire volume on a 4GiB device:
MBR for one partition spanning the entire volume on a 8GiB device:
MBR for one partition spanning the entire volume on a 16GiB device:
MBR for one partition spanning the entire volume on a 32GiB device: