Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jul 31 '11 at 18:02

This question came from our site for professional and enthusiast programmers.

1 Answer 1

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.

need an app what could create partition layout MBRs for given sizes

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 parted on it, creating the partition table and partition, then truncate the file to the first 512 bytes. You can now reuse that file, copying it to the start of as many volumes as you'd like.

MBR for one partition spanning the entire volume on a 4GiB device:

0000000 b8fa 1000 d08e 00bc b8b0 0000 d88e c08e
0000010 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000020 be00 07be 0438 0b75 c683 8110 fefe 7507
0000030 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000040 024c 13cd 00ea 007c eb00 00fe 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000
*
00001b0 0000 0000 0000 0000 2ff7 000d 0000 0000
00001c0 1001 0383 ffe0 0800 0000 f800 007f 0000
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
0000200

MBR for one partition spanning the entire volume on a 8GiB device:

0000000 b8fa 1000 d08e 00bc b8b0 0000 d88e c08e
0000010 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000020 be00 07be 0438 0b75 c683 8110 fefe 7507
0000030 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000040 024c 13cd 00ea 007c eb00 00fe 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000
*
00001b0 0000 0000 0000 0000 4f7f 0000 0000 0000
00001c0 1001 0383 ffe0 0800 0000 f800 00ff 0000
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
0000200

MBR for one partition spanning the entire volume on a 16GiB device:

0000000 b8fa 1000 d08e 00bc b8b0 0000 d88e c08e
0000010 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000020 be00 07be 0438 0b75 c683 8110 fefe 7507
0000030 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000040 024c 13cd 00ea 007c eb00 00fe 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000
*
00001b0 0000 0000 0000 0000 d709 0003 0000 0000
00001c0 1001 0383 ffe0 0800 0000 f800 01ff 0000
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
0000200

MBR for one partition spanning the entire volume on a 32GiB device:

0000000 b8fa 1000 d08e 00bc b8b0 0000 d88e c08e
0000010 befb 7c00 00bf b906 0200 a4f3 21ea 0006
0000020 be00 07be 0438 0b75 c683 8110 fefe 7507
0000030 ebf3 b416 b002 bb01 7c00 80b2 748a 8b01
0000040 024c 13cd 00ea 007c eb00 00fe 0000 0000
0000050 0000 0000 0000 0000 0000 0000 0000 0000
*
00001b0 0000 0000 0000 0000 7ca5 0001 0000 0000
00001c0 1001 0383 ffe0 0800 0000 f800 03ff 0000
00001d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00001f0 0000 0000 0000 0000 0000 0000 0000 aa55
0000200
share|improve this answer
1  
Yes, I know that MBR isn't a file, but I format the SD card using that exact 512bytes + mkfs ;) Thanks for the wiki link, it will come handy! Basically, I wanted an app what can open such a file, and edit it. –  fonix232 Jul 30 '11 at 13:10
    
Oh, so you mean a binary file editor, or hex editor? –  Delan Azabani Jul 30 '11 at 14:51
    
Not really, but more likely a GUI editor. Something what may emulate a selected-size drive (4/8/16GB in this case), let me add the four partitions, set their size, type, etc, and create the MBR, and write it into a file. Or better, open such existing files! –  fonix232 Jul 30 '11 at 15:33
    
Oh, I see. I'm not aware of any GUI program that does all that in one, so my best suggestion is to use a GUI partition editor like palimpsest or gparted, then use dd if=/dev/sdx of=mbr bs=512 count=1 to copy the MBR out. –  Delan Azabani Jul 31 '11 at 2:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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