Skip to content

Commit

Permalink
Fix acquisition of UUID (#2077)
Browse files Browse the repository at this point in the history
* Fix acquisition of UUID

* Fix inadequate solution

* Add check for UUID
  • Loading branch information
codefiles authored Sep 20, 2023
1 parent b1e0068 commit 3e2999b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
26 changes: 17 additions & 9 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ def format(
else:
self._perform_formatting(part_mod.safe_fs_type, part_mod.safe_dev_path)

lsblk_info = self._fetch_part_info(part_mod.safe_dev_path)

part_mod.partuuid = lsblk_info.partuuid
part_mod.uuid = lsblk_info.uuid

def _perform_partitioning(
self,
part_mod: PartitionModification,
Expand Down Expand Up @@ -354,15 +359,10 @@ def _perform_partitioning(

# the partition has a real path now as it was created
part_mod.dev_path = Path(partition.path)

lsblk_info = self._fetch_partuuid(part_mod.dev_path)

part_mod.partuuid = lsblk_info.partuuid
part_mod.uuid = lsblk_info.uuid
except PartitionException as ex:
raise DiskError(f'Unable to add partition, most likely due to overlapping sectors: {ex}') from ex

def _fetch_partuuid(self, path: Path) -> LsblkInfo:
def _fetch_part_info(self, path: Path) -> LsblkInfo:
attempts = 3
lsblk_info: Optional[LsblkInfo] = None

Expand All @@ -371,16 +371,24 @@ def _fetch_partuuid(self, path: Path) -> LsblkInfo:
time.sleep(attempt_nr + 1)
lsblk_info = get_lsblk_info(path)

if lsblk_info.partuuid:
if lsblk_info.partuuid and lsblk_info.uuid:
break

self.partprobe(path)

if not lsblk_info or not lsblk_info.partuuid:
if not lsblk_info:
debug(f'Unable to get partition information: {path}')
raise DiskError(f'Unable to get partition information: {path}')

if not lsblk_info.partuuid:
debug(f'Unable to determine new partition uuid: {path}\n{lsblk_info}')
raise DiskError(f'Unable to determine new partition uuid: {path}')

debug(f'partuuid found: {lsblk_info.json()}')
if not lsblk_info.uuid:
debug(f'Unable to determine new uuid: {path}\n{lsblk_info}')
raise DiskError(f'Unable to determine new uuid: {path}')

debug(f'partition information found: {lsblk_info.json()}')

return lsblk_info

Expand Down
6 changes: 1 addition & 5 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from pathlib import Path
from typing import Any, List, Optional, TYPE_CHECKING, Union, Dict, Callable

from ..lib.disk.device_model import get_lsblk_info

from . import disk
from .exceptions import DiskError, ServiceException, RequirementError, HardwareIncompatibilityError, SysCallError
from .general import SysCommand
Expand Down Expand Up @@ -937,9 +935,7 @@ def _add_limine_bootloader(
self.pacman.strap('limine')
info(f"Limine boot partition: {boot_partition.dev_path}")

# XXX: We cannot use `root_partition.uuid` since corresponds to the UUID of the root
# partition before the format.
root_uuid = get_lsblk_info(root_partition.safe_dev_path).uuid
root_uuid = root_partition.uuid

def create_pacman_hook(contents: str):
HOOK_DIR = "/etc/pacman.d/hooks"
Expand Down

0 comments on commit 3e2999b

Please sign in to comment.