- // Second, do Linux partitions....
- i = 0;
- while (i < gpt_part_count && new_mbr_part_count <= 3) {
+ // Second, do Linux partitions. Note that we start from the END of the
+ // partition list, so as to maximize the space covered by the 0xEE
+ // partition if there are several Linux partitions before other hybridized
+ // partitions.
+ i = gpt_part_count - 1; // Note that gpt_part_count can't be 0; filtered by check_gpt()
+ while (i < gpt_part_count && new_mbr_part_count <= 3) { // if too few GPT partitions, i loops around to a huge value