Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import platform
from pathlib import Path

from parted import Device, Disk, DiskException, FileSystem, Geometry, IOException, Partition, PartitionException, freshDisk, getAllDevices, getDevice, newDisk
Expand All @@ -10,6 +11,7 @@
find_lsblk_info,
get_all_lsblk_info,
get_lsblk_info,
linux_root_guid,
mount,
udev_sync,
umount,
Expand All @@ -26,7 +28,6 @@
LsblkInfo,
ModificationStatus,
PartitionFlag,
PartitionGUID,
PartitionModification,
PartitionTable,
SubvolumeModification,
Expand Down Expand Up @@ -339,6 +340,7 @@ def _setup_partition(
block_device: BDevice,
disk: Disk,
requires_delete: bool,
arch: str | None = None,
) -> None:
# when we require a delete and the partition to be (re)created
# already exists then we have to delete it first
Expand Down Expand Up @@ -394,7 +396,7 @@ def _setup_partition(

if disk.type == PartitionTable.GPT.value:
if part_mod.is_root():
partition.type_uuid = PartitionGUID.LINUX_ROOT_X86_64.bytes
partition.type_uuid = linux_root_guid(arch).bytes
elif PartitionFlag.LINUX_HOME not in part_mod.flags and part_mod.is_home():
partition.setFlag(PartitionFlag.LINUX_HOME.flag_id)

Expand Down Expand Up @@ -536,11 +538,19 @@ def partition(
# don't touch existing partitions
filtered_part = [p for p in modification.partitions if not p.exists()]

arch = platform.machine()

for part_mod in filtered_part:
# if the entire disk got nuked then we don't have to delete
# any existing partitions anymore because they're all gone already
requires_delete = modification.wipe is False
self._setup_partition(part_mod, modification.device, disk, requires_delete=requires_delete)
self._setup_partition(
part_mod,
modification.device,
disk,
requires_delete=requires_delete,
arch=arch,
)

disk.commit()

Expand Down
9 changes: 8 additions & 1 deletion archinstall/lib/disk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from archinstall.lib.command import SysCommand, run
from archinstall.lib.exceptions import DiskError, SysCallError
from archinstall.lib.log import debug, info, warn
from archinstall.lib.models.device import LsblkInfo
from archinstall.lib.models.device import LsblkInfo, PartitionGUID


class LsblkOutput(BaseModel):
Expand Down Expand Up @@ -196,3 +196,10 @@ def swapon(path: Path) -> None:
SysCommand(['swapon', str(path)])
except SysCallError as err:
raise DiskError(f'Could not enable swap {path}:\n{err.message}')


def linux_root_guid(arch: str | None) -> PartitionGUID:
if arch == 'aarch64':
return PartitionGUID.LINUX_ROOT_AARCH64

return PartitionGUID.LINUX_ROOT_X86_64
Comment on lines +201 to +205

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered making this a class method of PartitionGUID but remembered this: #4461

This seems like an appropriate place anyway.

4 changes: 3 additions & 1 deletion archinstall/lib/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,11 @@ def from_string(cls, s: str) -> Self | None:

class PartitionGUID(Enum):
"""
A list of Partition type GUIDs (lsblk -o+PARTTYPE) can be found here: https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
A list of Partition type GUIDs (lsblk -o+PARTTYPE) can be found here:
https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
"""

LINUX_ROOT_AARCH64 = 'B921B045-1DF0-41C3-AF44-4C6F280D3FAE'
LINUX_ROOT_X86_64 = '4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709'

@property
Expand Down