From 931610d5bb85813b5c9854784f024b08728ca04c Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sat, 15 Nov 2014 15:56:08 -0800 Subject: [PATCH] disk_util: Set priority and successful attributes in new images Mark the initial copy of CoreOS as 'successful' and with a non-zero priority. Required to boot with a stricter interpretation of the partition selection scheme which ignores partitions that have a priority of zero. The new grub implementation follows this rule and is what the original ChromeOS spec used too. For the sake of completeness if multiple partitions are configured in the json file with this feature they will be prioritized in disk-order. --- build_library/disk_layout.json | 3 ++- build_library/disk_util | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build_library/disk_layout.json b/build_library/disk_layout.json index 7f5c75fddd..2b20e54677 100644 --- a/build_library/disk_layout.json +++ b/build_library/disk_layout.json @@ -29,7 +29,8 @@ "blocks":"2097152", "fs_blocks":"262144", "fs_type":"ext2", - "mount":"/usr" + "mount":"/usr", + "features": ["prioritize"] }, "4":{ "label":"USR-B", diff --git a/build_library/disk_util b/build_library/disk_util index dd0054564d..a561b604e6 100755 --- a/build_library/disk_util +++ b/build_library/disk_util @@ -278,6 +278,7 @@ def WritePartitionTable(options, config=None, partitions=None): syslinux = False hybrid = None + prioritize = [] for partition in partitions.itervalues(): if partition['type'] != 'blank': Cgpt('add', '-i', partition['num'], @@ -293,6 +294,8 @@ def WritePartitionTable(options, config=None, partitions=None): hybrid = partition['num'] if 'syslinux' in features: syslinux = True + if 'prioritize' in features: + prioritize.append(partition) if hybrid: # Enable legacy boot flag and generate a hybrid MBR partition table @@ -314,6 +317,10 @@ def WritePartitionTable(options, config=None, partitions=None): with open(options.disk_image, 'r+') as image_fd: image_fd.write(mbr_code) + prioritize.reverse() + for i, partition in enumerate(prioritize): + Cgpt('add', '-i', partition['num'], '-S1', '-P', i+1, options.disk_image) + Cgpt('show', options.disk_image)