What is the maximum number of partitions with EFI?

Solution 1:

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.

Solution 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.

Solution 3:

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.)