23

I'm reading the docs over at CentOS.org.

In section 25.1.2. Partitions: Turning One Drive Into Many, there is the following statement:

The partition table is divided into four sections or four primary partitions. A primary partition is a partition on a hard drive that can contain only one logical drive (or section). Each section can hold the information necessary to define a single partition, meaning that the partition table can define no more than four partitions.

I don't understand why there can only ever be four partitions. Is this just the way it was designed in the beginning? Can there really only ever be 4 primary partitions?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
Jongosi
  • 354
  • 1
  • 2
  • 11

4 Answers4

36

Is this just the way it was designed in the beginning? Can there really only ever be 4 primary partitions?

Yes, that's exactly it. The partition table at the front of an MBR disk (as opposed to a GPT style disk) has a very strict data-structure that dates from the 1980's when space was a precious, precious thing. The design decision way back then was to only allow four partitions, but allow one of them to be an 'extended' partition that was a pointer to another spot on the disk that could contain a lot more 'logical' partitions.

(This is the same reason why MBR formatted disks have trouble with 2TB+ disks. 512 byte size clusters, and 32bit fields containing cluster-counts for partition size = 2TB maximum disk size. A 4KB cluster size punts the problem down the road a ways.)

GPT is an updated method of handling partitioning that doesn't have these limitations.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
  • 1
    It's also only a restriction on IDE-type discs. SCSI, for example, have 8, with the third by convention being an overlap partition that spans the entire device. – MadHatter Apr 22 '14 at 11:40
  • 18
    @MadHatter the partition table by itself is storage type agnostic. It seems that you are describing Solaris Slices, which are a slightly different concept. – the-wabbit Apr 22 '14 at 11:45
  • 3
    I haven't thought that to be the case, but you're dead right that most of my SCSI partitioning experience is from Solaris. I bow to your correction, and thank you! – MadHatter Apr 22 '14 at 11:46
  • 4
    Actually, [extended partitions came much later](https://en.wikipedia.org/wiki/Master_Boot_Record#Overview); IBM PC DOS 2.0 introduced the MBR as part of its HDD support in March 1983, but it wasn't until [3.3 (April 1987) that extended partitions became available](https://en.wikipedia.org/wiki/Timeline_of_DOS_operating_systems#1980.E2.80.931995:_Important_Events_in_DOS_History). – user Apr 22 '14 at 14:38
  • Actually, the "extended partition" simply points to another MBR-style partition table, which in turn can also contain only 4 entries (each of which could be an extended partition entry that points to another partition table, which can also contain 4 entries (each of which could be an extended partition …)) I reality some operating systems only allow extended partitions in slot 4 and if there is one, then slots 2 and 3 need to be empty, so what you end up in practice is a singly-linked list of partition tables with a primary in slot 1 and a link to the next table in slot 4. – Jörg W Mittag Apr 22 '14 at 14:56
  • @JörgWMittag You are right. E.g. Windows (upto 2000, not sure about XP land later) would do strange things if the extended partition was anything else but 4. You could leave 2 and 3 blank though. Didn't like an unused part of the disk between 2 partitions either. The partition behind it would sometimes get corrupted for unclear reasons. – Tonny Apr 23 '14 at 12:52
26

There are only four because the data structures for the MBR partition table only allow for exactly four records describing partitions:

You could create additional partition tables nested in definitions of what is called an "extended partition", but the partitions defined therein are traditionally called "logical" partitions. Keep in mind that this is a limitation of this specific implementation. Other partition types, like the GUID partition table, do not share this limitation.

the-wabbit
  • 40,319
  • 13
  • 105
  • 169
3

A primary partition is a low level concept - it's to do with the initial booting process of the machine, and is based on a well defined set of specifications. It's thus really quite hard to change the number of primary partitions, because a lot of disk and motherboard manufacturers would have to agree to implement a new standard.

Practically speaking though, this is a moot point - it's of relevance at 'boot time' for getting your OS started in the first place, but that's about it. Extended partitions exist, which allow more partitions on your disk. You couldn't boot off them though.

More fundamentally - most operating systems work with more disk abstraction - logical volume managers - which means that actual on-disk topology is largely irrelevant. (And indeed, it's often not desirable to segment your pool of storage)

Sobrique
  • 3,697
  • 2
  • 14
  • 34
  • 1
    I think you're wrong about not being able to boot off one; I think GRUB will happily boot Linux from an extended partition. Other than that, I mostly agree with you. – MadHatter Apr 22 '14 at 11:38
  • GRUB itself has to be on a primary partition though - the low level bootstrap starts grub, that then lets you pick. – Sobrique Apr 22 '14 at 11:41
  • 1
    The stage 1 loader shouldn't be on a partition at all; it should be in the MBR. The rest of the code lives inside the `/boot` partition, and as I say, I believe that can happily be an extended partition. – MadHatter Apr 22 '14 at 11:42
  • Fair enough. I'll go read up and do my homework. But I suppose still supports the case that whilst primary partitions are limited, that limit is largely irrelevant now. – Sobrique Apr 22 '14 at 11:49
  • Sorry, that should read "*stage 1 and 1.5 loaders*", and even then, stage 1.5 is in unused post-MBR-pre-partition space. But stage 2 is firmly in the `/boot` partition, and I'm still confident that can be on a logical partition. I agree with you that it's fairly irrelevant in a modern LVM context. – MadHatter Apr 22 '14 at 11:49
  • 1
    "... because a lot of disk and motherboard manufacturers would have to agree to implement a new standard." What? How that? It is completely irrelevant for the disk, and even the mainboard shouldn't need to care about that. All the mainboard needs to do is read sector 0 and execute its code. Recognizing partitions is the job of that code. – glglgl Apr 23 '14 at 05:29
0

Not sure if I am late to the party , but here it goes:

The Partition table size is designed to be 64 bytes and each partition table is 16 bytes. 16 * 4 = 64 and hence there is no more space for any other entries in the partition table.

In order to workaround this the fourth entry has a provision for an Extended partition entry which can have sequential pointers to other Extended partitions.

https://docs.microsoft.com/en-us/windows/win32/fileio/basic-and-dynamic-disks

Guru
  • 1