4

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?

1
  • The size of the field in the GPT header that holds the number of partition entries has a fixed size of 4 bytes, so defacto it can support a maximum value of 2^32. But individual OSs usually place further limits on the max count. The minimum (number of partition entries) seems to be 128, even if you have less partitions on the drive.
    – mo FEAR
    Dec 31, 2023 at 19:47

3 Answers 3

5

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.

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.

1
  • 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
    Jan 23, 2017 at 19:55
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.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .