MCPcopy Index your code
hub / github.com/archlinux/archinstall / suggest_multi_disk_layout

Function suggest_multi_disk_layout

archinstall/lib/disk/disk_menu.py:701–805  ·  view source on GitHub ↗
(
	devices: list[BDevice],
	filesystem_type: FilesystemType | None = None,
)

Source from the content-addressed store, hash-verified

699
700
701async def suggest_multi_disk_layout(
702 devices: list[BDevice],
703 filesystem_type: FilesystemType | None = None,
704) -> list[DeviceModification]:
705 if not devices:
706 return []
707
708 # Not really a rock solid foundation of information to stand on, but it's a start:
709 # https://www.reddit.com/r/btrfs/comments/m287gp/partition_strategy_for_two_physical_disks/
710 # https://www.reddit.com/r/btrfs/comments/9us4hr/what_is_your_btrfs_partitionsubvolumes_scheme/
711 min_home_partition_size = Size(40, Unit.GiB, SectorSize.default())
712 # rough estimate taking in to account user desktops etc. TODO: Catch user packages to detect size?
713 desired_root_partition_size = Size(32, Unit.GiB, SectorSize.default())
714 mount_options = []
715
716 if not filesystem_type:
717 filesystem_type = await select_main_filesystem_format()
718
719 # find proper disk for /home
720 possible_devices = [d for d in devices if d.device_info.total_size >= min_home_partition_size]
721 home_device = max(possible_devices, key=lambda d: d.device_info.total_size) if possible_devices else None
722
723 # find proper device for /root
724 devices_delta = {}
725 for device in devices:
726 if device is not home_device:
727 delta = device.device_info.total_size - desired_root_partition_size
728 devices_delta[device] = delta
729
730 sorted_delta: list[tuple[BDevice, Size]] = sorted(devices_delta.items(), key=lambda x: x[1])
731 root_device: BDevice | None = sorted_delta[0][0]
732
733 if home_device is None or root_device is None:
734 text = tr('The selected drives do not have the minimum capacity required for an automatic suggestion\n')
735 text += tr('Minimum capacity for /home partition: {}GiB\n').format(min_home_partition_size.format_size(Unit.GiB))
736 text += tr('Minimum capacity for Arch Linux partition: {}GiB').format(desired_root_partition_size.format_size(Unit.GiB))
737
738 _ = await Notify(text).show()
739 return []
740
741 if filesystem_type == FilesystemType.BTRFS:
742 mount_options = await select_mount_options()
743
744 device_paths = ', '.join(str(d.device_info.path) for d in devices)
745
746 debug(f'Suggesting multi-disk-layout for devices: {device_paths}')
747 debug(f'/root: {root_device.device_info.path}')
748 debug(f'/home: {home_device.device_info.path}')
749
750 root_device_modification = DeviceModification(root_device, wipe=True)
751 home_device_modification = DeviceModification(home_device, wipe=True)
752
753 root_device_sector_size = root_device_modification.device.device_info.sector_size
754 home_device_sector_size = home_device_modification.device.device_info.sector_size
755
756 using_gpt = device_handler.partition_table.is_gpt()
757
758 # add boot partition to the root device

Callers 1

Calls 15

format_sizeMethod · 0.95
add_partitionMethod · 0.95
SizeClass · 0.90
trFunction · 0.90
NotifyClass · 0.90
debugFunction · 0.90
DeviceModificationClass · 0.90
select_mount_optionsFunction · 0.85
_boot_partitionFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected