flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Extended Partition Boot Sectors

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 17 Apr 2010, 23:36
I needed to see how the partition table looked for logical partitions, so I dded the boot sector off my fat16 partition for my OS. Wikipedia says the partition table should contain 1. An entry for the partition it's part of, and 2. The address of the next ebr relative to the partition I'm reading from. When I look at the hex of the boot sector(formatted by GParted), there is no partition table at all. What do I put in my boot loader for the partition table and why isn't it there?
Post 17 Apr 2010, 23:36
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 18 Apr 2010, 08:01
You should look for tartition table in master boot record, not in boot sector. There you will find starting address of extended partition. Extended boot record will be there
Post 18 Apr 2010, 08:01
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 18 Apr 2010, 10:29
I know where the extended partition, but wikipedia describes an extended partition as a linked list of logical partition boot records. That means the first partition of the extended partition just points to another(I know you know what a linked list is, I'm just saying), so logically, one would think there would be a 2 entry partition table in the boot record of the extended partition and each subsequent logical partitions, but there isn't a partition table at all in the logical partition I'm studying.
Post 18 Apr 2010, 10:29
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4336
Location: Now
edfed 18 Apr 2010, 10:40
wikipedia is not a good reference for programming, prefer wiki.osdev.org

Smile
Post 18 Apr 2010, 10:40
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 18 Apr 2010, 11:08
I use both. A lot of the time it's obvious one uses a lot of the other's content verbatim. In this case osdev's content is minuscule compared to wikipedia's.
Post 18 Apr 2010, 11:08
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 18 Apr 2010, 11:23
Tyler,

What exactly have you dded? Physical sector at LBA 0 (CHS 0/0/1), or logical sector 0 of logical disk (i.e. drive, C: for example)? Logical sector 0 contains boot sector.
Post 18 Apr 2010, 11:23
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 18 Apr 2010, 12:14
I used "dd if=/dev/sda8 count=1 of=irrelevant" (The partition in question is /dev/sda8 it''s fat16)
Post 18 Apr 2010, 12:14
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 18 Apr 2010, 15:20
So you dded the volume boot record, not the master boot record. I don't think the VBR is supposed to store anything other than the boot loader code and the "BIOS" parameter block (for MS volumes).
Post 18 Apr 2010, 15:20
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 18 Apr 2010, 15:25
Please, take a look at what I have on my disk:
Let's start with MBR:
Code:
Offset       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F

000000000   33 C0 8E D0 BC 00 7C 8E  C0 8E D8 BE 00 7C BF 00   3ÀŽÐ¼.|ŽÀŽØ¾.|¿.
000000010   06 B9 00 02 FC F3 A4 50  68 1C 06 CB FB B9 04 00   .¹..üó¤Ph..Ëû¹..
000000020   BD BE 07 80 7E 00 00 7C  0B 0F 85 0E 01 83 C5 10   ½¾.€~..|..…..ƒÅ.
000000030   E2 F1 CD 18 88 56 00 55  C6 46 11 05 C6 46 10 00   âñÍ.ˆV.UÆF..ÆF..
000000040   B4 41 BB AA 55 CD 13 5D  72 0F 81 FB 55 AA 75 09   ´A»ªUÍ.]r..ûUªu.
000000050   F7 C1 01 00 74 03 FE 46  10 66 60 80 7E 10 00 74   ÷Á..t.þF.f`~..t
000000060   26 66 68 00 00 00 00 66  FF 76 08 68 00 00 68 00   &fh....fÿv.h..h.
000000070   7C 68 01 00 68 10 00 B4  42 8A 56 00 8B F4 CD 13   |h..h..´BŠV.‹ôÍ.
000000080   9F 83 C4 10 9E EB 14 B8  01 02 BB 00 7C 8A 56 00   ŸƒÄ.žë.¸..».|ŠV.
000000090   8A 76 01 8A 4E 02 8A 6E  03 CD 13 66 61 73 1C FE   Šv.ŠN.Šn.Í.fas.þ
0000000A0   4E 11 75 0C 80 7E 00 80  0F 84 8A 00 B2 80 EB 84   N.u.€~.€.„Š.²€ë„
0000000B0   55 32 E4 8A 56 00 CD 13  5D EB 9E 81 3E FE 7D 55   U2äŠV.Í.]ëž.>þ}U
0000000C0   AA 75 6E FF 76 00 E8 8D  00 75 17 FA B0 D1 E6 64   ªunÿv.è..u.ú°Ñæd
0000000D0   E8 83 00 B0 DF E6 60 E8  7C 00 B0 FF E6 64 E8 75   èƒ.°ßæ`è|.°ÿædèu
0000000E0   00 FB B8 00 BB CD 1A 66  23 C0 75 3B 66 81 FB 54   .û¸.»Í.f#Àu;f.ûT
0000000F0   43 50 41 75 32 81 F9 02  01 72 2C 66 68 07 BB 00   CPAu2.ù..r,fh.».
000000100   00 66 68 00 02 00 00 66  68 08 00 00 00 66 53 66   .fh....fh....fSf
000000110   53 66 55 66 68 00 00 00  00 66 68 00 7C 00 00 66   SfUfh....fh.|..f
000000120   61 68 00 00 07 CD 1A 5A  32 F6 EA 00 7C 00 00 CD   ah...Í.Z2öê.|..Í
000000130   18 A0 B7 07 EB 08 A0 B6  07 EB 03 A0 B5 07 32 E4   . ·.ë. ¶.ë. µ.2ä
000000140   05 00 07 8B F0 AC 3C 00  74 09 BB 07 00 B4 0E CD   ...‹ð¬<.t.»..´.Í
000000150   10 EB F2 F4 EB FD 2B C9  E4 64 EB 00 24 02 E0 F8   .ëòôëý+Éädë.$.àø
000000160   24 02 C3 49 6E 76 61 6C  69 64 20 70 61 72 74 69   $.ÃInvalid parti
000000170   74 69 6F 6E 20 74 61 62  6C 65 00 45 72 72 6F 72   tion table.Error
000000180   20 6C 6F 61 64 69 6E 67  20 6F 70 65 72 61 74 69    loading operati
000000190   6E 67 20 73 79 73 74 65  6D 00 4D 69 73 73 69 6E   ng system.Missin
0000001A0   67 20 6F 70 65 72 61 74  69 6E 67 20 73 79 73 74   g operating syst
0000001B0   65 6D 00 00 00 63 7B 9A  C3 58 E8 06 00 50 80 01   em...c{šÃXè..P€.
0000001C0   01 00 07 FE FF FF 3F 00  00 00 5B 24 40 01 00 FE   ...þÿÿ?...[$@..þ
0000001D0   FF FF 0C FE FF FF 9A 24  40 01 3D 26 9C 00 00 FE   ÿÿ.þÿÿš$@.=&œ..þ
0000001E0   FF FF 0F FE FF FF 32 05  C0 08 0D 54 82 1C 00 00   ÿÿ.þÿÿ2.À..T‚...
0000001F0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 AA   ..............Uª
    

Here I have my partition table:
Code:
80 01 01 00 07 FE FF FF 3F 00 00 00 5B 24 40 01 <- NTFS
00 FE FF FF 0C FE FF FF 9A 24 40 01 3D 26 9C 00 <- FAT32
00 FE FF FF 0F FE FF FF 32 05 C0 08 0D 54 82 1C <- extended
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <- empty
    

Extended partition: LBA = 08C00532, Size = 1C82540D
Let's take a look at what resides at the given LBA:
Code:
Offset       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F

11800A6400   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6410   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6420   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6430   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6440   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6450   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6460   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6470   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6480   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6490   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A64A0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A64B0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A64C0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A64D0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A64E0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A64F0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6500   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6510   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6520   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6530   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6540   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6550   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6560   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6570   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6580   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A6590   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A65A0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A65B0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 FE   ...............þ
11800A65C0   FF FF 07 FE FF FF 3F 00  00 00 34 0A 80 02 00 FE   ÿÿ.þÿÿ?...4.€..þ
11800A65D0   FF FF 05 FE FF FF 73 0A  80 02 73 0A 80 02 00 00   ÿÿ.þÿÿs.€.s.€...
11800A65E0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
11800A65F0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 AA   ..............Uª
    

Here I have Extended boot record with two partitions in the list:
Code:
00 FE FF FF 07 FE FF FF 3F 00 00 00 34 0A 80 02 <- NTFS
00 FE FF FF 05 FE FF FF 73 0A 80 02 73 0A 80 02 <- extended
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <- empty
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <- empty
    

Now let's take a look at what is at LBA 02800A73. Note, that this LBA is relative
to the extended boot record, not MBR (the beginning of disk).
Code:
Offset       0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F

16801F4A00   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A10   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A20   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A30   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A40   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A50   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A60   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A70   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A80   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4A90   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4AA0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4AB0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4AC0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4AD0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4AE0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4AF0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B00   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B10   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B20   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B30   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B40   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B50   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B60   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B70   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B80   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4B90   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4BA0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4BB0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 FE   ...............þ
16801F4BC0   FF FF 0B FE FF FF 3F 00  00 00 34 0A 80 02 00 FE   ÿÿ.þÿÿ?...4.€..þ
16801F4BD0   FF FF 05 FE FF FF E6 14  00 05 73 0A 80 02 00 00   ÿÿ.þÿÿæ...s.€...
16801F4BE0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
16801F4BF0   00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 AA   ..............Uª
    

Here we have one more extended boot record which points to one more extended partition...
and so on. As you can see - it's a chain of extended partitions.
Post 18 Apr 2010, 15:25
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 19 Apr 2010, 01:10
I'm not looking in the wrong place, it has the 0x55AA and fits the description of a fat16 boot record. It's part of my extended partition.
"tyler@laptop:~$ sudo dd if=/dev/sda of=Desktop/img skip=180667053 count=1"
Code:
    

The hex editor put those things there.
Post 19 Apr 2010, 01:10
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 19 Apr 2010, 07:01
Could you redo the entire process and post the results like zhak did?
Post 19 Apr 2010, 07:01
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 20 Apr 2010, 03:48
ManOfSteel: What do you want?
Here's the MBR - "dd if=/dev/sda of=Desktop/mbr count=1"
Code:
    
Post 20 Apr 2010, 03:48
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 20 Apr 2010, 04:21
The point behind my question is I want to know how to get the lba of my logical partition at boot time, can anyone help with another way to do that, please?
Post 20 Apr 2010, 04:21
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 20 Apr 2010, 07:54
it's simple.
1. you read MBR to get access to a partition table.
2. you check partition type to see if it's an extended partition or not
- if not, then check the next entry in the partition table
- if yes, then starting LBA of the extended partition is at offset 8 of the partition table entry relative to address of sector your partition table resides in (for MBR it's 0).
3. you read ext. boot record at LBA you found on step 2
4. you check partition type. if it's not an extended partition, then it's a logical volume in the extended partition. you get it's LBA at offset 8. This LBA is relative to the extended boot record address.

you can follow the idea with the listing i provided above.
Post 20 Apr 2010, 07:54
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 20 Apr 2010, 12:12
Tyler wrote:
The point behind my question is I want to know how to get the lba of my logical partition at boot time, can anyone help with another way to do that, please?

Start by checking LBA location 0x3de1783.
Post 20 Apr 2010, 12:12
View user's profile Send private message Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 22 Apr 2010, 15:03
It seems that you are looking at the boot sector of the extended partition ,but the sector where the extended partition begins is another.
you must begin reading the mbr then follow the link to the first sector of the extended partition,on this sector there is a table with pointers to the next logical partition and another pointer to the boot sector ,the boot sector do not have a partition table.
Post 22 Apr 2010, 15:03
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 22 Apr 2010, 23:42
Octavio wrote:

It seems that you are looking at the boot sector of the extended partition ,but the sector where the extended partition begins is another.

That is an awesome sentence, I should use syntax like that.Smile

I think I see now what you've all been trying to tell me. The boot sector identified as /dev/sda8 is not the same as the extended boot record with the partition table. Right?
Post 22 Apr 2010, 23:42
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 23 Apr 2010, 00:43
Tyler,

Doesn't /dev/sda8 look like logical partition in extended partition? There is some info in Linux Partition HOWTO regarding this.
Post 23 Apr 2010, 00:43
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4336
Location: Now
edfed 23 Apr 2010, 06:16
while looking at very old thread on the forum, (last pages), i've found this link:
http://www.nondot.org/sabre/os/articles/FileSystems/
looks very interrestng. Very Happy

it is the next step of partition game.
Post 23 Apr 2010, 06:16
View user's profile Send private message Visit poster's website Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 23 Apr 2010, 07:19
Tyler wrote:
The boot sector identified as /dev/sda8 is not the same as the extended boot record with the partition table. Right?

It's exactly that.

Now check LBA location 0x3de1783.
Post 23 Apr 2010, 07:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.