From 0f2c6ed0079da1e251eb340e195f5869e2250969 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 25 Jul 2012 11:52:46 -0400 Subject: [PATCH] Fix GPT code to allocate space for /2/ tables. 17408 is the size of the table being made, but there's one at the beginning and one at the end. --- src/sbin/mkefiboot | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sbin/mkefiboot b/src/sbin/mkefiboot index fb695ede..a50cb5bf 100755 --- a/src/sbin/mkefiboot +++ b/src/sbin/mkefiboot @@ -92,15 +92,16 @@ def macmunge(imgfile, product): def mkefidisk(efiboot, outfile): '''Make a bootable EFI disk image out of the given EFI boot image.''' - # pjones sez: "17408 is the size of the GPT tables parted creates" - partsize = os.path.getsize(efiboot) + 17408 - disksize = round_to_blocks(17408 + partsize, 512) + # pjones sez: "17408 is the size of the GPT tables parted creates, + # but there are two of them." + partsize = os.path.getsize(efiboot) + 17408 * 2 + disksize = round_to_blocks(2 * 17408 + partsize, 512) with LoopDev(outfile, disksize) as loopdev: with DMDev(loopdev, disksize) as dmdev: check_call(["parted", "--script", "/dev/mapper/%s" % dmdev, "mklabel", "gpt", "unit", "b", - "mkpart", "'EFI System Partition'", "fat32", "17408", str(partsize), + "mkpart", "'EFI System Partition'", "fat32", "34816", str(partsize), "set", "1", "boot", "on"], stdout=PIPE, stderr=PIPE) partdev = "/dev/mapper/{0}p1".format(dmdev) with open(efiboot, "rb") as infile: