summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrent s <r00t@square-r00t.net>2019-08-18 22:28:52 -0400
committerbrent s <r00t@square-r00t.net>2019-08-18 22:28:52 -0400
commit0c0f6ee81bd89be5bfcc892b60889b0fc0830c4f (patch)
tree7f08d5f98c40f1e53c84873a9cde986cca4fd8b9
parentc149a7b3b78e3384b8258344d9800c56af23059f (diff)
downloadOpTools-0c0f6ee81bd89be5bfcc892b60889b0fc0830c4f.tar.xz
fixed! no more messages about missing UUID
-rwxr-xr-xsys/BootSync/bootsync.py44
-rw-r--r--sys/BootSync/prep.txt88
2 files changed, 60 insertions, 72 deletions
diff --git a/sys/BootSync/bootsync.py b/sys/BootSync/bootsync.py
index fd39c37..774ba1b 100755
--- a/sys/BootSync/bootsync.py
+++ b/sys/BootSync/bootsync.py
@@ -14,26 +14,6 @@ import psutil
from lxml import etree
- # def get_file_kernel_ver(self, kpath):
- # # Gets the version of a kernel file.
- # kpath = os.path.abspath(os.path.expanduser(kpath))
- # _kinfo = {}
- # with open(kpath, 'rb') as f:
- # _m = magic.detect_from_content(f.read())
- # for i in _m.name.split(','):
- # l = i.strip().split()
- # # Note: this only grabs the version number.
- # # If we want to get e.g. the build user/machine, date, etc.,
- # # then we need to join l[1:].
- # # We technically don't even need a dict, either. We can just iterate.
- # # TODO.
- # _kinfo[l[0].lower()] = (l[1] if len(l) > 1 else None)
- # if 'version' not in _kinfo:
- # raise RuntimeError('Cannot deterimine the version of {0}'.format(
- # kpath))
- # else:
- # return (_kinfo['version'])
-
class BootSync(object):
def __init__(self, cfg = None, *args, **kwargs):
if not cfg:
@@ -117,7 +97,13 @@ class BootSync(object):
d = dict(map(lambda i: i.split('='), line))
if d.get('TYPE') == 'squashfs':
continue
- self.blkids[d['DEVNAME']] = d.get('PARTUUID', d['UUID'])
+ try:
+ self.blkids[d['DEVNAME']] = d.get('UUID', d['PARTUUID'])
+ except KeyError:
+ try:
+ self.blkids[d['DEVNAME']] = d['UUID']
+ except KeyError:
+ continue
c = subprocess.run(['/usr/bin/findmnt',
'--json',
'-T', '/boot'],
@@ -233,14 +219,16 @@ class BootSync(object):
disk = os.path.abspath(os.path.expanduser(esp.attrib['path']))
with open(os.path.join(mount, 'grub/grub.cfg'), 'w') as f:
for line in _grubcfg.splitlines():
- # if re.search(r'^\s*search\s+(.*)\s(-u|--fs-uuid)', line):
- # pass
- i = re.sub(r'(?<!\=UUID\=){0}'.format(self.dummy_uuid),
- self.blkids[disk],
- line)
# If the array is in a degraded state, this will still let us at LEAST boot.
- i = re.sub(r'\s+--hint=[\'"]?mduuid/[a-f0-9]{32}[\'"]?', '', i)
- f.write('{0}\n'.format(i))
+ line = re.sub(r'\s+--hint=[\'"]?mduuid/[a-f0-9]{32}[\'"]?', '', line)
+ line = re.sub(r'^(\s*set\s+root=){0}$'.format(self.dummy_uuid),
+ self.blkids[disk],
+ line)
+ line = re.sub(r'(?<!\=UUID\=){0}'.format(self.dummy_uuid),
+ self.blkids[disk],
+ line)
+ line = re.sub('/boot', '', line)
+ f.write('{0}\n'.format(line))
return()
def _getRunningKernel(self):
diff --git a/sys/BootSync/prep.txt b/sys/BootSync/prep.txt
index 6514763..66e2ea4 100644
--- a/sys/BootSync/prep.txt
+++ b/sys/BootSync/prep.txt
@@ -7,50 +7,50 @@ PREPARATION:
2.) Install GRUB2 to *each ESP*. See sample.config.xml for context for the below examples.
- grub-install \
- --boot-directory=/mnt/boot1 \
- --bootloader-id=Arch \
- --efi-directory=/mnt/boot1/ \
- --target=x86_64-efi \
- --no-nvram \
- --recheck
-
- grub-install \
- --boot-directory=/mnt/boot1 \
- --bootloader-id="Arch (Fallback)" \
- --efi-directory=/mnt/boot1/ \
- --target=x86_64-efi \
- --no-nvram \
- --recheck
-
- grub-install \
- --boot-directory=/mnt/boot2 \
- --bootloader-id=Arch \
- --efi-directory=/mnt/boot2/ \
- --target=x86_64-efi \
- --no-nvram \
- --recheck
-
- grub-install \
- --boot-directory=/mnt/boot2 \
- --bootloader-id="Arch (Fallback)" \
- --efi-directory=/mnt/boot2/ \
- --target=x86_64-efi \
- --no-nvram \
- --recheck
+ grub-install \
+ --boot-directory=/mnt/boot1 \
+ --bootloader-id=Arch \
+ --efi-directory=/mnt/boot1/ \
+ --target=x86_64-efi \
+ --no-nvram \
+ --recheck
+
+ grub-install \
+ --boot-directory=/mnt/boot1 \
+ --bootloader-id="Arch (Fallback)" \
+ --efi-directory=/mnt/boot1/ \
+ --target=x86_64-efi \
+ --no-nvram \
+ --recheck
+
+ grub-install \
+ --boot-directory=/mnt/boot2 \
+ --bootloader-id=Arch \
+ --efi-directory=/mnt/boot2/ \
+ --target=x86_64-efi \
+ --no-nvram \
+ --recheck
+
+ grub-install \
+ --boot-directory=/mnt/boot2 \
+ --bootloader-id="Arch (Fallback)" \
+ --efi-directory=/mnt/boot2/ \
+ --target=x86_64-efi \
+ --no-nvram \
+ --recheck
3.) Prepare the ESPs. See sample.config.xml for context for the below examples.
- efibootmgr \
- --create \
- --disk /dev/sdd \
- --part 1 \
- --loader /EFI/Arch/grubx64.efi \
- --label "Arch (Fallback)"
-
- efibootmgr \
- --create \
- --disk /dev/sdb \
- --part 1 \
- --loader /EFI/Arch/grubx64.efi \
- --label "Arch"
+ efibootmgr \
+ --create \
+ --disk /dev/sdd \
+ --part 1 \
+ --loader /EFI/Arch/grubx64.efi \
+ --label "Arch (Fallback)"
+
+ efibootmgr \
+ --create \
+ --disk /dev/sdb \
+ --part 1 \
+ --loader /EFI/Arch/grubx64.efi \
+ --label "Arch"