What is the maximum number of partitions with EFI?

3

I was wondering what is the maximum number of partition on an GPT-partitionned drive under Linux.

The GPT partition table can contain up to 128 partitions, but the device nodes for /dev/sda? (as described here, block device of major number 8) only allow /dev/sda1 up to /dev/sda15.

Does that means that there cannot be more that 15 partitions on a drive, even on a GPT-partitionned drive?

Guillaume Brunerie

Posted 2011-07-05T21:38:17.010

Reputation: 458

Answers

4

Let's read the fine source.

In block/partitions/efi.c, the place to set up gpt partitions is efi_partition(). Here decides the maximum number of partitions:

for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) {

num_partition_entries comes from gpt header on the disk, so the maximum number is state->limit - 1. state is the argument of this function, and this function is called from check_part(), from check_partition() in the same file, and there comes

state->limit = disk_max_parts(hd);

So the limit is disk_max_parts(),

static inline int disk_max_parts(struct gendisk *disk)
{
        if (disk->flags & GENHD_FL_EXT_DEVT)
                return DISK_MAX_PARTS;
        return disk->minors;
}

So if the disk device has GENHD_FL_EXT_DEVT /* allow extended devt */ (loop device, generic ATA/ATAPI disk, SCSI disk, MD RAID), the limit is DISK_MAX_PARTS (256), otherwise it's minors.

In conclusion, usually the maximum number Linux kernel supports is 255.

Lingzhu Xiang

Posted 2011-07-05T21:38:17.010

Reputation: 206

2

Well, I think that's where using UUIDs comes in to play. In that case, you don't address a block device as /dev/{h,s}dXY but rather, by the device's UUID. Certainly in that case, the limit would be supremely beyond excess of 128.

James T Snell

Posted 2011-07-05T21:38:17.010

Reputation: 5 726

It is not true, because number defining stored partitions on disk in GPT header is only 32 bit. That mean you can't have more than 2^32 partitions. – Misaz – 2017-01-23T19:55:49.643

2

No, it means that Linux has a problem. ☺ But we knew that already.

Who told you that the EFI partition table contains up to 128 partitions? That person cannot read specifications. As I've said before, 128 entries of 128 bytes each is the minimum size that is required by the EFI Specification, not the size of an EFI partition table, and certainly not the maximum size.

(Strictly speaking the minimum, first mentioned in version 1.10 of the EFI Specification, is 16KiB total for all partition entries, but not including the header block. With the conventional 128 byte entry length, that's a minimum of 128 entries.)

JdeBP

Posted 2011-07-05T21:38:17.010

Reputation: 23 855