Trying to sort out a boot issue
This commit is contained in:
parent
24a384cddb
commit
46c8e74a73
|
|
@ -78,13 +78,14 @@ class BlockDevice():
|
|||
return self.info[key]
|
||||
|
||||
class Partition():
|
||||
def __init__(self, path, part_id=None, size=-1, filesystem=None, mountpoint=None):
|
||||
def __init__(self, path, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False):
|
||||
if not part_id: part_id = os.path.basename(path)
|
||||
self.path = path
|
||||
self.part_id = part_id
|
||||
self.mountpoint = mountpoint
|
||||
self.filesystem = filesystem # TODO: Autodetect if we're reusing a partition
|
||||
self.size = size # TODO: Refresh?
|
||||
self.encrypted = encrypted
|
||||
|
||||
def __repr__(self, *args, **kwargs):
|
||||
return f'Partition({self.path}, fs={self.filesystem}, mounted={self.mountpoint})'
|
||||
|
|
|
|||
|
|
@ -60,14 +60,17 @@ class Installer():
|
|||
entry.write('initrd /initramfs-linux.img\n')
|
||||
## blkid doesn't trigger on loopback devices really well,
|
||||
## so we'll use the old manual method until we get that sorted out.
|
||||
# UUID = simple_command(f"blkid -s PARTUUID -o value /dev/{os.path.basename(args['drive'])}{args['partitions']['2']}").decode('UTF-8').strip()
|
||||
# entry.write('options root=PARTUUID={UUID} rw intel_pstate=no_hwp\n'.format(UUID=UUID))
|
||||
|
||||
|
||||
for root, folders, uids in os.walk('/dev/disk/by-partuuid'):
|
||||
for uid in uids:
|
||||
real_path = os.path.realpath(os.path.join(root, uid))
|
||||
if not os.path.basename(real_path) == os.path.basename(self.partition.path): continue
|
||||
|
||||
entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
|
||||
if self.partition.encrypted:
|
||||
entry.write(f'options cryptdevice=PARTUUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
|
||||
else:
|
||||
entry.write(f'options root=PARTUUID={uid} rw intel_pstate=no_hwp\n')
|
||||
return True
|
||||
break
|
||||
raise RequirementError(f'Could not identify the UUID of {partition}, there for {self.mountpoint}/boot/loader/entries/arch.conf will be broken until fixed.')
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class luks2():
|
|||
if '/' in mountpoint: os.path.basename(mountpoint) # TODO: Raise exception instead?
|
||||
sys_command(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --key-file {os.path.abspath(key_file)} --type luks2')
|
||||
if os.path.islink(f'/dev/mapper/{mountpoint}'):
|
||||
return Partition(f'/dev/mapper/{mountpoint}')
|
||||
return Partition(f'/dev/mapper/{mountpoint}', encrypted=True)
|
||||
|
||||
def close(self, mountpoint):
|
||||
sys_command(f'cryptsetup close /dev/mapper/{mountpoint}')
|
||||
|
|
|
|||
Loading…
Reference in New Issue