MBR Partition table...
 
Notifications
Clear all

MBR Partition table, first entry 0, but not the second

7 Posts
3 Users
0 Likes
411 Views
CyberGonzo
(@cybergonzo)
Posts: 100
Estimable Member
Topic starter
 

Hi,

Concerning MBR -> Partition Table -> 4 entries -> LBA

Up till recently (today ) I thought that if the LBA of the first entry is 0, the remainder of the 4 entries is 0 as well !? So no point to check further.

However, it seems that the first entry can be empty (0) and that valid(*) content is present in the second entry ?

(*) still need to check, I only have a one 512 byte sector file to check / debug right now.

Is this possible ? What formatting software does it this way, it seems odd to me, unless I'm missing something, in which case, kindly enlighten me )

Cheers.

 
Posted : 04/09/2012 2:16 am
(@athulin)
Posts: 1156
Noble Member
 

Up till recently (today ) I thought that if the LBA of the first entry is 0, the remainder of the 4 entries is 0 as well !? So no point to check further.

Can't say I heard of that method before.

I'm not sure if there is any formal specification of the MBR partition table format. I do know that the standard Microsoft boot code looks at all four slots before it gives up – I see little reason to make any other assumptions or try to 'optimize' an investigation by finding other criteria, unless it is backed by pretty solid research.

I also 'know' that the partition type field indicates if the slot is considered to contain valid data. Partition type = 0 means the slot is considered empty. It doesn't say anthing about any following slots, though.

However, it seems that the first entry can be empty (0) and that valid(*) content is present in the second entry ?

(*) still need to check, I only have a one 512 byte sector file to check / debug right now.

Is this possible ? What formatting software does it this way, it seems odd to me, …

As I don't know the size of the disk or the contents of the partition table slot, I may be barking up the wrong tree, but onsider the following scenarios

A. Create partion 1 covering half the drive. It is recorded in slot 1. Then, create partition 2, covering the remainder of the disk. That is recorded in slot 2. Now delete partition 1. What is the result – does the contents of slot 2 move to slot 1, or does it remain in place? (That probably depends on the partitioning software you use, and possibly also on the release – one version may do one thing, a later version something else.)

B. In case your partition covers the entire disk, consider the possibility that after scenario 1 and slot 2 remains occupied, the partition is moved and resized. FDISK can't do that, as far as I know, but tools like PartitionMagic, Gparted, etc usually can. What happens now? Is the partition still recorded in slot 2?

Try to identify the source of your 'LBA = 0' conception, and examine it closer. If it doesn't hold up, considered it bogus, and avoid using it as a basis for your future investigations.

If it is important to your case, check up on whatever partitioning software the user of the disk you are looking at had available.

 
Posted : 04/09/2012 11:51 am
CyberGonzo
(@cybergonzo)
Posts: 100
Estimable Member
Topic starter
 

Partition type = 0 means the slot is considered empty. It doesn't say anthing about any following slots, though.

Your feedback and examples make sense, I had not thought of it this way. I thought the MBR / Table would be rewritten each time a re-format of some sort was performed but of course that is not needed nor guaranteed.

Frankly I don't know where I got it from as I implemented this a loooong time ago and it seemed to work great until yesterday.

Anyway, with this confirmed I feel better to change the code for all and leave this in as a FIX. Whoohoo, another productive day -)

Thanks

 
Posted : 04/09/2012 2:25 pm
jaclaz
(@jaclaz)
Posts: 5133
Illustrious Member
 

Besides what athulin stated, it is also quite common to have partitions in the partition table NOT in the "right" order, still AFAIK mostly provoked by fiddling with creating/deleting partitions.

MBRWIZ, as an example, has a provision to re-order partition table entries "Sort partition table"
http//mbrwizard.com/

jaclaz

 
Posted : 04/09/2012 3:46 pm
CyberGonzo
(@cybergonzo)
Posts: 100
Estimable Member
Topic starter
 

it is also quite common to have partitions in the partition table NOT in the "right" order

Ah, thanks for that !
I will have another look at the code then to see how I deal with that !

 
Posted : 04/09/2012 4:28 pm
(@athulin)
Posts: 1156
Noble Member
 

Try to identify the source of your 'LBA = 0' conception, and examine it closer. If it doesn't hold up, considered it bogus, and avoid using it as a basis for your future investigations.

I see that the Sourceforge project 'disktype' relies on LBA start = 0 as an indication that the partition table slot is unused. (Source code – file dos.c)

Additionally, Brouwer's 'maximal specification' suggests that 'A partition descriptor is unused if either the Partition Type or the Partition Size is zero. In this case all its entries must be zero. ' (See http// www . win . tue . nl/~aeb/partitions/)

So there are some variations out there. They're probably saved by some kind of 'all fields must be zero' requirement.

Added The 'first slot empty' scenario is covered in Brouwer's section 2.12

Early MSDOS filled the partition table starting at the end. In particular, in the case of only one partition, the descriptor was stored in the fourth primary slot. These days DOS FDISK starts at the beginning, but other systems, like Unixware, still start at the end. Also Iomega writes the single partition of a ZIP disk in the last entry (so that it has to be mounted as /dev/sda4 or /dev/hdc4 or so).

 
Posted : 10/09/2012 1:44 pm
jaclaz
(@jaclaz)
Posts: 5133
Illustrious Member
 

Slightly OT, but not much, another example IMHO worth a mention is the ZIP disk format.

There are actually TWO possible formats for it, one as "superfloppy" (no MBR nor partition table - though I have never seen one) and one as a "partitioned disk".
BUT there is only one partition, it must have a 64/32 HS geometry and must be in 4th entry in the partition table.
The "theory and info" is also here
http//www.win.tue.nl/~aeb/
http//www.win.tue.nl/~aeb/linux/zip/zip-1.html
and here is a "real life" example
http//cheesehead-techblog.blogspot.it/2011/11/booting-old-via-epia-5000l-motherboard.html

The actual question on how exactly a 750 Mb ZIP disk is partitioned/formatted is still AFAIK "open"
http//www.msfn.org/board/topic/147545-create-a-bootable-cddvd-from-a-set-of-floppies/page__st__20

Should anyone have this info, it would be nice to have this little piece of the puzzle added.

jaclaz

 
Posted : 10/09/2012 2:01 pm
Share: