mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-27 00:21:44 +02:00
Merge pull request #353 from marineam/gptprio
disk_util: Set priority and successful attributes in new images
This commit is contained in:
commit
204f0024fb
@ -29,7 +29,8 @@
|
|||||||
"blocks":"2097152",
|
"blocks":"2097152",
|
||||||
"fs_blocks":"262144",
|
"fs_blocks":"262144",
|
||||||
"fs_type":"ext2",
|
"fs_type":"ext2",
|
||||||
"mount":"/usr"
|
"mount":"/usr",
|
||||||
|
"features": ["prioritize"]
|
||||||
},
|
},
|
||||||
"4":{
|
"4":{
|
||||||
"label":"USR-B",
|
"label":"USR-B",
|
||||||
|
@ -278,6 +278,7 @@ def WritePartitionTable(options, config=None, partitions=None):
|
|||||||
|
|
||||||
syslinux = False
|
syslinux = False
|
||||||
hybrid = None
|
hybrid = None
|
||||||
|
prioritize = []
|
||||||
for partition in partitions.itervalues():
|
for partition in partitions.itervalues():
|
||||||
if partition['type'] != 'blank':
|
if partition['type'] != 'blank':
|
||||||
Cgpt('add', '-i', partition['num'],
|
Cgpt('add', '-i', partition['num'],
|
||||||
@ -293,6 +294,8 @@ def WritePartitionTable(options, config=None, partitions=None):
|
|||||||
hybrid = partition['num']
|
hybrid = partition['num']
|
||||||
if 'syslinux' in features:
|
if 'syslinux' in features:
|
||||||
syslinux = True
|
syslinux = True
|
||||||
|
if 'prioritize' in features:
|
||||||
|
prioritize.append(partition)
|
||||||
|
|
||||||
if hybrid:
|
if hybrid:
|
||||||
# Enable legacy boot flag and generate a hybrid MBR partition table
|
# 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:
|
with open(options.disk_image, 'r+') as image_fd:
|
||||||
image_fd.write(mbr_code)
|
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)
|
Cgpt('show', options.disk_image)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user