2

I'm trying to understand the ms-dos partition table, and there's the following diagram:

screen

It comes from this site. Almost everything is pretty clear to me, but there's one thing I don't get. As you can see, the third partition is an extended partition, and it has several logical disks. The extended and primary entries in MBR look the same. Both have partition type, starting sector and number of sectors which describe the partitions.

  • Where is the info that would link to the first EBR on the extended partition?
  • How does the system know what to look for on the extended partition?

Let's say that we've lost the extended entry in MBR. How to restore it? If I create a new extended entry via fdisk, it won't see the logical disks. How to connect the first EBR to the extended entry in MBR?

2

I made an 300MB extended partition with a 100MB logical partition; deleted just the extended partition; then recreated it - all with fdisk. At every stage I observed the first logical partition's EBR sector, and it turned out, that when fdisk creates the extended partition, it resets the first EBR.

Then I re-created the first logical partition with the same size, and I was able to mount it and read the little test data I left there.

Then deleted them again, and created it again, but with a 200MB logical partition. I was able to mount then too, but the file system was still 100MB.


So if you already created the extended partition, I'm afraid, you too have overwritten the first EBR.

I guess, if you know exactly the logical partition's start and end sectors, you can recreate and use all of them. But if you do not know exact sectors, then fdisk will write EBR into a filesystem data sector and corrupt it.

Creating a logical partition that fills the whole extended partition will probably make the first logical partition accessible.

I also read, that parted's rescue command can find lost partitions.

  • That makes sense. I checked this, and it changes the first EBR. I restored only the first EBR, and all logical disks can be seen again. But how does the system know about the first EBR? If this were a normal partition, it wouldn't search for EBR, right? So, is it because of the type of the partition? – Mikhail Morfikov Jan 16 '14 at 14:07
  • I found this: "When a partition is created and its type is set to "Extended," an extended partition table is created. In essence, the extended partition is like a disk drive in its own right — it has a partition table that points to one or more partitions (now called logical partitions, as opposed to the four primary partitions) contained entirely within the extended partition itself." -- so, it looks like that the type of an extended partition automatically tells the system to search for its "MBR", but in the reality it's EBR. – Mikhail Morfikov Jan 16 '14 at 14:23
1

The information on the first partition in the EBR is located in the first sector of the extended partition. You can find that info, e.g. in the wikipedia article on extended boot record

Any following EBR partition information is pointed to from the first partition information (i.e. chained until the 'pointer' is zero).

  • Yes, I know -- it's even on the photo in the question. – Mikhail Morfikov Jan 16 '14 at 11:27

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.