Synchronize GRUB across multiple disks.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

Incorporate prep.txt with config file?
should look something like this:
#!/usr/bin/env python
import os
import re
import shutil
import subprocess
esp = {'/dev/vdb': ('Arch (Fallback)', '/mnt/boot2'),
'/dev/vda': ('Arch', '/mnt/boot1')}
part = 1
for dev, (label, mnt) in esp.items():
grubdir = os.path.join(mnt, 'grub')
if os.path.isdir(grubdir):
efi =['efibootmgr'], stdout = subprocess.PIPE)
efi_lines = efi.stdout.decode('utf-8').strip().splitlines()
efi_entries = {}
for l in efi_lines:
i = l.split(None, 1)
k = i[1].strip()
v = re.sub(r'^Boot(?P<boot_id>[A-Fa-f0-9]+).*$', r'\g<boot_id>', i[0])
efi_entries[k] = v
boot_id = efi_entries.get(label)
if not boot_id:
print('Could not find {0}'.format(label))
cmd =['efibootmgr',
'-b', boot_id,
stdout = subprocess.PIPE)
cmd =['grub-install',
cmd =['efibootmgr',
'--disk', dev,
'--part', str(part),
'--loader', '/EFI/Arch/grubx64.efi',
'--label', label])