index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | archinstall/lib/disk.py | 36 |
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index fdc2fbc5..31e8e007 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -73,26 +73,31 @@ class BlockDevice(): raise DiskError(f'Could not locate backplane info for "{self.path}"') if self.info['type'] == 'loop': - for drive in json.loads(b''.join(sys_command(f'losetup --json', hide_from_log=True)).decode('UTF_8'))['loopdevices']: + for drive in json.loads(b''.join(sys_command(['losetup', '--json'], hide_from_log=True)).decode('UTF_8'))['loopdevices']: if not drive['name'] == self.path: continue return drive['back-file'] elif self.info['type'] == 'disk': return self.path + elif self.info['type'][:4] == 'raid': + # This should catch /dev/md## raid devices + return self.path elif self.info['type'] == 'crypt': if 'pkname' not in self.info: raise DiskError(f'A crypt device ({self.path}) without a parent kernel device name.') return f"/dev/{self.info['pkname']}" + else: + log(f"Unknown blockdevice type for {self.path}: {self.info['type']}", level=LOG_LEVELS.Debug) # if not stat.S_ISBLK(os.stat(full_path).st_mode): # raise DiskError(f'Selected disk "{full_path}" is not a block device.') @property def partitions(self): - o = b''.join(sys_command(f'partprobe {self.path}')) + o = b''.join(sys_command(['partprobe', self.path])) #o = b''.join(sys_command('/usr/bin/lsblk -o name -J -b {dev}'.format(dev=dev))) - o = b''.join(sys_command(f'/usr/bin/lsblk -J {self.path}')) + o = b''.join(sys_command(['/usr/bin/lsblk', '-J', self.path])) if b'not a block device' in o: raise DiskError(f'Can not read partitions off something that isn\'t a block device: {self.path}') @@ -187,6 +192,17 @@ class Partition(): return f'Partition(path={self.path}, fs={self.filesystem}{mount_repr})' @property + def uuid(self) -> str: + """ + Returns the PARTUUID as returned by lsblk. + This is more reliable than relying on /dev/disk/by-partuuid as + it doesn't seam to be able to detect md raid partitions. + """ + lsblk = b''.join(sys_command(f'lsblk -J {self.path}')) + for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']: + return partition['partuuid'] + + @property def encrypted(self): return self._encrypted @@ -203,7 +219,7 @@ class Partition(): if not self._encrypted: return self.path else: - for blockdevice in json.loads(b''.join(sys_command('lsblk -J')).decode('UTF-8'))['blockdevices']: + for blockdevice in json.loads(b''.join(sys_command(['lsblk', '-J'])).decode('UTF-8'))['blockdevices']: if (parent := self.find_parent_of(blockdevice, os.path.basename(self.path))): return f"/dev/{parent}" # raise DiskError(f'Could not find appropriate parent for encrypted partition {self}') @@ -241,9 +257,15 @@ class Partition(): if self.allow_formatting is False: log(f"Partition {self} is not marked for formatting.", level=LOG_LEVELS.Debug) return False - elif self.target_mountpoint == '/boot' and self.has_content(): - log(f"Partition {self} is a boot partition and has content inside.", level=LOG_LEVELS.Debug) - return False + elif self.target_mountpoint == '/boot': + try: + if self.has_content(): + log(f"Partition {self} is a boot partition and has content inside.", level=LOG_LEVELS.Debug) + return False + except SysCallError as err: + log(err.message, LOG_LEVELS.Debug) + log(f"Partition {self} was identified as /boot but we could not mount to check for content, continuing!", level=LOG_LEVELS.Debug) + pass return True |