partitioning ?
partitioning ?
I am wondering what physically gets written out to the HDD when paritioning a harddrive?
What I know is that the mbr holds the partition table. The partition table in the mbr only has spaces for 4 16byte entries.
Using gpart you can create primary partitions , extended partition , or logical partitions.
I believe to create a primary partition it is just modifying/adding 1 entry in the 4 spaces in the partition table telling it where and how big it is. This would explain why you can only have 4 primary partitions on a HDD.
I am not fully sure if I am completely correct on how primary partitions get created so if somebody could elaborate on anything I am forgetting that would be appreciated.
And I am still wondering if their is a limit on the number of logical partitions you can create/have in an extended partition?
What I know is that the mbr holds the partition table. The partition table in the mbr only has spaces for 4 16byte entries.
Using gpart you can create primary partitions , extended partition , or logical partitions.
I believe to create a primary partition it is just modifying/adding 1 entry in the 4 spaces in the partition table telling it where and how big it is. This would explain why you can only have 4 primary partitions on a HDD.
I am not fully sure if I am completely correct on how primary partitions get created so if somebody could elaborate on anything I am forgetting that would be appreciated.
And I am still wondering if their is a limit on the number of logical partitions you can create/have in an extended partition?
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: partitioning ?
http://wiki.osdev.org/Partition_Table
When you add/delete a partition, the OS updates the information in the tables.
-JL
When you add/delete a partition, the OS updates the information in the tables.
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: partitioning ?
Yeah, no. It's not like that. The partial MBR in each extended partition may contain only one partition descriptor and optionally a pointer to another extended partition. There is no limit to this nesting.Now when you create an 'extended' partition (and correct me if I'm wrong), this partition bootsector is filled with
N partition entries (same structure as in the MBR). Then, as a sector is 512 bytes long and a partition entry is 16 bytes long, I guess you can have max. 512/16 = 32 extended partitions.
If a trainstation is where trains stop, what is a workstation ?
Re: partitioning ?
Ok , let me see if I got this straight.
If one was to write a partitioning program like gpart.
To make a primary partition the program would just have to update/modify a 16byte entry
located on the mbr at starting location 446 (this is where the 64 byte partition table begins )
each 16byte entry is structured this way
http://en.wikipedia.org/wiki/Master_boot_record#ref_a
By reading this http://en.wikipedia.org/wiki/Extended_boot_record I agree in theory with gerryg400. The logical partitions in an extended each have at the begining (i.e first sector of the logical partition) has 2 entries in their partition table for the previous and next logical partitions "so is a link list fashion structure to traverse and find where a logical partition starts.
What I don't get is how the extended partition is held or the starting logical partition since what is it's previous element is it just zeros or the address of itself for both entries in that partition table? Is their something that differentates between a primary and extend partition in the partition table , I see no field for that just active or not a bootable ?
Other then the formatting part which isn't really part of partitioning a drive it's part of formating a drive. It seems not so hard to write a program to partition a drive and then call another tool like mkfs-ext4 ,...etc to format that partition.
I see that their is also GUID , EFI , other partition schemes but what os's or gpart like tools create them or use them. Curious ?
If one was to write a partitioning program like gpart.
To make a primary partition the program would just have to update/modify a 16byte entry
located on the mbr at starting location 446 (this is where the 64 byte partition table begins )
each 16byte entry is structured this way
http://en.wikipedia.org/wiki/Master_boot_record#ref_a
By reading this http://en.wikipedia.org/wiki/Extended_boot_record I agree in theory with gerryg400. The logical partitions in an extended each have at the begining (i.e first sector of the logical partition) has 2 entries in their partition table for the previous and next logical partitions "so is a link list fashion structure to traverse and find where a logical partition starts.
What I don't get is how the extended partition is held or the starting logical partition since what is it's previous element is it just zeros or the address of itself for both entries in that partition table? Is their something that differentates between a primary and extend partition in the partition table , I see no field for that just active or not a bootable ?
Other then the formatting part which isn't really part of partitioning a drive it's part of formating a drive. It seems not so hard to write a program to partition a drive and then call another tool like mkfs-ext4 ,...etc to format that partition.
I see that their is also GUID , EFI , other partition schemes but what os's or gpart like tools create them or use them. Curious ?
-
- Member
- Posts: 127
- Joined: Sat Sep 29, 2007 5:43 pm
- Location: Amsterdam, The Netherlands
Re: partitioning ?
Hi
When using the MBR standard, every partition has a partition type. The types 0x05 and 0x0F indicate that a partition is an extended partition in both the MBR and the EBR. The MBR basically has four entries, they are your primary partitions. One of those partitions, and only one, can be an extended partition that points to an EBR instead of a VBR (volume boot record). Every EBR may contain up to two entries. One of them is your logical partition, the other may be your extended partition.
Yours faithfully
S.J.R. van Schaik.
When using the MBR standard, every partition has a partition type. The types 0x05 and 0x0F indicate that a partition is an extended partition in both the MBR and the EBR. The MBR basically has four entries, they are your primary partitions. One of those partitions, and only one, can be an extended partition that points to an EBR instead of a VBR (volume boot record). Every EBR may contain up to two entries. One of them is your logical partition, the other may be your extended partition.
Yours faithfully
S.J.R. van Schaik.
Re: partitioning ?
ok, when I use a hexeditor to view the partition table of a harddrive I had.
It gave me only this entry
On this harddrive I already know that their is only one primary no extended drives so only one entry in the partition table all the rest are zeroed out.
80 means it is active/bootable
01 01 00 is for the CHS
07 is a partition type (not sure what are the vaild values and their meaning but I am assuming
from the above post that if I put a 0x5 or 0xF it would mean extended partition)
FE FF FF is the end in CHS form
3F 00 00 00 is the begining in LBA
C1 97 42 25 is the end in LBA
what I don't get is the drive has 625142448 sectors total but the partition table was set to only allow you to use 625121217 sectors ? Why didn't microsoft or the os that created the only primary partition use the whole thing ?
And why does the begining of the primary partition begin on sector 63 = 3F 00 00 00 (little endian)
what is the reason for the space from sectors 1 - 63 is their any use or can I zero these out with out effecting anything?
It gave me only this entry
On this harddrive I already know that their is only one primary no extended drives so only one entry in the partition table all the rest are zeroed out.
Code: Select all
80 01 01 00 07 FE FF FF 3F 00 00 00 C1 97 42 25
01 01 00 is for the CHS
07 is a partition type (not sure what are the vaild values and their meaning but I am assuming
from the above post that if I put a 0x5 or 0xF it would mean extended partition)
FE FF FF is the end in CHS form
3F 00 00 00 is the begining in LBA
C1 97 42 25 is the end in LBA
what I don't get is the drive has 625142448 sectors total but the partition table was set to only allow you to use 625121217 sectors ? Why didn't microsoft or the os that created the only primary partition use the whole thing ?
And why does the begining of the primary partition begin on sector 63 = 3F 00 00 00 (little endian)
what is the reason for the space from sectors 1 - 63 is their any use or can I zero these out with out effecting anything?
Re: partitioning ?
The statement that you are "not sure" means you did not study the link that piranha gave you, or at least not closely enough to realize that the first external link in the "see also" section is labeled "System ID byte values ("Partition Types") for known filesystems". That link can make you sure. Googling for "partition types" would also have helped.Sam111 wrote:07 is a partition type (not sure what are the vaild values and their meaning but I am assuming
from the above post that if I put a 0x5 or 0xF it would mean extended partition)
1) Read documentation, 2) Google, 3) ask. In this order.
Because it is still customary to partition at "cylinder boundaries". There is unused space in the first "cylinder" (between the MBR and the first partition, i.e. sectors 1-63), and the last, incomplete "cylinder". The small percentage of usable space lost is considered a viable payoff for not having problems in this department. Some partitioning tools can use this additional space, though. Which OS's in which versions might have problems here is beyond my knowledge, though.what I don't get is the drive has 625142448 sectors total but the partition table was set to only allow you to use 625121217 sectors ? Why didn't microsoft or the os that created the only primary partition use the whole thing ?
See above. By custom partitions are considered to begin at "cylinder" boundaries. Since the MBR already occupies sector 0, the rest of the first cylinder is not assigned to a partition. (But see below.)And why does the begining of the primary partition begin on sector 63 = 3F 00 00 00 (little endian)
Yes you can use that space. But be aware that other people also thought that space would be a nifty place to put things. Boot managers, disk encryption tools and the like have been known to store data in this area. And since there's no file system etc. to tell if it's been used, and by whom, and if it might still be required, all bets are off. So the wise won't touch it, or rely on it being available.what is the reason for the space from sectors 1 - 63 is their any use or can I zero these out with out effecting anything?
Every good solution is obvious once you've found it.
Re: partitioning ?
ok , I see
one other thing I was curious about is
I know you can have at most 4 primary partitions.
But I have read you can only have one extended partition is this true. Because to me in theory you could mark each of the 4 partition entries in the partition table of the mbr as being extended. Why the restriction in tools like gpart ,...etc ?
one other thing I was curious about is
I know you can have at most 4 primary partitions.
But I have read you can only have one extended partition is this true. Because to me in theory you could mark each of the 4 partition entries in the partition table of the mbr as being extended. Why the restriction in tools like gpart ,...etc ?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: partitioning ?
Google provided (in your case, yet again) the answer:
You can have up to 4 extended partitions. Many OSes can only deal with one though.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: partitioning ?
There is no reason to have more than a single extended partition in the MBR, you can still chain extended partitions as many times as you want, however, OS's and partitioning software arbitrarily limit the depth so it doesn't infinitely recurse.
Re: partitioning ?
That's right but I have support for multiple extended partitions in my volume manager. I use sequential numeration through all extended partitions as a basic and additionally I use separate numeration within each extended partition. To prevent infinite recursive lookup I use maximum 255 partitions per physical drive (of both primary and additional partition types).
If you have seen bad English in my words, tell me what's wrong, please.
Re: partitioning ?
Not entirely. They can overlap but it's a very dangerous thing to do and many partitioning tools will complain. Windows and Linux won't however. I tried - it works.pitfall wrote:Creating a primary partition is 'not' just modifying one entry in the 4 spaces left in the primary partition table. Let's say your storage device is divided in 'N' sectors, then you'll have to modify this entry with values that fits on requirement : Do not overlap any existing partition.
Each extended partition may only contain two entries (!). They're at the same offset & size as in the MBR; you can just only use the first two of the four entries. The first of those two is a regular partition and the second is - you guessed it - another extended partitions. It's extended partitions all the way down by the way.pitfall wrote:Now when you create an 'extended' partition (and correct me if I'm wrong), this partition bootsector is filled with
N partition entries (same structure as in the MBR). Then, as a sector is 512 bytes long and a partition entry is 16 bytes long, I guess you can have max. 512/16 = 32 extended partitions.
The OSes round the drive space down to the nearest multiple that can be represented as if it were formatted with CHS. So, it decides on a virtual drive layout (255 heards, 63 sectors per track, 16 heads) and finds out how many sectors can fit in that.Sam111 wrote:what I don't get is the drive has 625142448 sectors total but the partition table was set to only allow you to use 625121217 sectors ? Why didn't microsoft or the os that created the only primary partition use the whole thing ?
625 142 448 / (255 * 63 * 16) = 2 432.08235
So you get 2432 fake clusters. The 0.08235 drops off and can't be used. So, calculate back to sectors:
2 432 * (255 * 63 * 16) = 625 121 280
And you lose the first track (of 63 sectors!) to the MBR. Hence, 625121217 exactly.
Disks used to be divided into "Tracks" which is a certain combo of head and cylinder. Partitions may only start on track boundaries, hence it's rounded up to 63.Sam111 wrote: And why does the begining of the primary partition begin on sector 63 = 3F 00 00 00 (little endian)
Most boot loaders (Grub etc.) use this space. Some awfully evil copy protection schemes do too and can cause your bootloader to be corrupted. Don't use it for your own goals, please.what is the reason for the space from sectors 1 - 63 is their any use or can I zero these out with out effecting anything?