index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton@hvornum.se> | 2022-01-14 08:11:30 +0100 |
---|---|---|
committer | Anton Hvornum <anton@hvornum.se> | 2022-01-14 08:11:30 +0100 |
commit | 4bd07ea19f17ef8c78bf12f0d3d50f71c2306c19 (patch) | |
tree | f417000cc16087dca1aed81391431ab85de7f513 /archinstall/lib/disk/user_guides.py | |
parent | 0bc3e94c795fdde55ccc9b233b897498dc7b498e (diff) | |
parent | e8b6b1b334fffe5c5de8c2951a974b0126ffd2b0 (diff) |
-rw-r--r-- | archinstall/lib/disk/user_guides.py | 84 |
diff --git a/archinstall/lib/disk/user_guides.py b/archinstall/lib/disk/user_guides.py index 8dbd15dd..a90ac506 100644 --- a/archinstall/lib/disk/user_guides.py +++ b/archinstall/lib/disk/user_guides.py @@ -1,14 +1,25 @@ +from __future__ import annotations import logging +from typing import Optional, Dict, Any, List, TYPE_CHECKING +# https://stackoverflow.com/a/39757388/929999 +if TYPE_CHECKING: + from .blockdevice import BlockDevice + from .helpers import sort_block_devices_based_on_performance, select_largest_device, select_disk_larger_than_or_close_to +from ..hardware import has_uefi from ..output import log -def suggest_single_disk_layout(block_device, default_filesystem=None, advanced_options=False): +def suggest_single_disk_layout(block_device :BlockDevice, + default_filesystem :Optional[str] = None, + advanced_options :bool = False) -> Dict[str, Any]: + if not default_filesystem: from ..user_interaction import ask_for_main_filesystem_format default_filesystem = ask_for_main_filesystem_format(advanced_options) - MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb + MIN_SIZE_TO_ALLOW_HOME_PART = 40 # GiB using_subvolumes = False + using_home_partition = False if default_filesystem == 'btrfs': using_subvolumes = input('Would you like to use BTRFS subvolumes with a default structure? (Y/n): ').strip().lower() in ('', 'y', 'yes') @@ -20,11 +31,19 @@ def suggest_single_disk_layout(block_device, default_filesystem=None, advanced_o } } + # Used for reference: https://wiki.archlinux.org/title/partitioning + + # 2 MiB is unallocated for GRUB on BIOS. Potentially unneeded for + # other bootloaders? + + # TODO: On BIOS, /boot partition is only needed if the drive will + # be encrypted, otherwise it is not recommended. We should probably + # add a check for whether the drive will be encrypted or not. layout[block_device.path]['partitions'].append({ # Boot "type" : "primary", - "start" : "5MB", - "size" : "513MB", + "start" : "3MiB", + "size" : "203MiB", "boot" : True, "encrypted" : False, "format" : True, @@ -33,10 +52,18 @@ def suggest_single_disk_layout(block_device, default_filesystem=None, advanced_o "format" : "fat32" } }) + + # Increase the UEFI partition if UEFI is detected. + # Also re-align the start to 1MiB since we don't need the first sectors + # like we do in MBR layouts where the boot loader is installed traditionally. + if has_uefi(): + layout[block_device.path]['partitions'][-1]['start'] = '1MiB' + layout[block_device.path]['partitions'][-1]['size'] = '512MiB' + layout[block_device.path]['partitions'].append({ # Root "type" : "primary", - "start" : "518MB", + "start" : "206MiB", "encrypted" : False, "format" : True, "mountpoint" : "/", @@ -45,13 +72,20 @@ def suggest_single_disk_layout(block_device, default_filesystem=None, advanced_o } }) + if has_uefi(): + layout[block_device.path]['partitions'][-1]['start'] = '513MiB' + + if not using_subvolumes and block_device.size >= MIN_SIZE_TO_ALLOW_HOME_PART: + using_home_partition = input('Would you like to create a separate partition for /home? (Y/n): ').strip().lower() in ('', 'y', 'yes') + # Set a size for / (/root) - if using_subvolumes or block_device.size < MIN_SIZE_TO_ALLOW_HOME_PART: + if using_subvolumes or block_device.size < MIN_SIZE_TO_ALLOW_HOME_PART or not using_home_partition: # We'll use subvolumes # Or the disk size is too small to allow for a separate /home + # Or the user doesn't want to create a separate partition for /home layout[block_device.path]['partitions'][-1]['size'] = '100%' else: - layout[block_device.path]['partitions'][-1]['size'] = f"{min(block_device.size, 20)}GB" + layout[block_device.path]['partitions'][-1]['size'] = f"{min(block_device.size, 20)}GiB" if default_filesystem == 'btrfs' and using_subvolumes: # if input('Do you want to use a recommended structure? (Y/n): ').strip().lower() in ('', 'y', 'yes'): @@ -69,17 +103,17 @@ def suggest_single_disk_layout(block_device, default_filesystem=None, advanced_o # else: # pass # ... implement a guided setup - elif block_device.size >= MIN_SIZE_TO_ALLOW_HOME_PART: + elif using_home_partition: # If we don't want to use subvolumes, # But we want to be able to re-use data between re-installs.. # A second partition for /home would be nice if we have the space for it layout[block_device.path]['partitions'].append({ # Home "type" : "primary", + "start" : f"{min(block_device.size, 20)}GiB", + "size" : "100%", "encrypted" : False, "format" : True, - "start" : f"{min(block_device.size+0.5, 20.5)}GB", - "size" : "100%", "mountpoint" : "/home", "filesystem" : { "format" : default_filesystem @@ -89,7 +123,10 @@ def suggest_single_disk_layout(block_device, default_filesystem=None, advanced_o return layout -def suggest_multi_disk_layout(block_devices, default_filesystem=None, advanced_options=False): +def suggest_multi_disk_layout(block_devices :List[BlockDevice], + default_filesystem :Optional[str] = None, + advanced_options :bool = False) -> Dict[str, Any]: + if not default_filesystem: from ..user_interaction import ask_for_main_filesystem_format default_filesystem = ask_for_main_filesystem_format(advanced_options) @@ -98,8 +135,8 @@ def suggest_multi_disk_layout(block_devices, default_filesystem=None, advanced_o # https://www.reddit.com/r/btrfs/comments/m287gp/partition_strategy_for_two_physical_disks/ # https://www.reddit.com/r/btrfs/comments/9us4hr/what_is_your_btrfs_partitionsubvolumes_scheme/ - MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb - ARCH_LINUX_INSTALLED_SIZE = 20 # Gb, rough estimate taking in to account user desktops etc. TODO: Catch user packages to detect size? + MIN_SIZE_TO_ALLOW_HOME_PART = 40 # GiB + ARCH_LINUX_INSTALLED_SIZE = 20 # GiB, rough estimate taking in to account user desktops etc. TODO: Catch user packages to detect size? block_devices = sort_block_devices_based_on_performance(block_devices).keys() @@ -119,11 +156,13 @@ def suggest_multi_disk_layout(block_devices, default_filesystem=None, advanced_o }, } + # TODO: Same deal as with the single disk layout, we should + # probably check if the drive will be encrypted. layout[root_device.path]['partitions'].append({ # Boot "type" : "primary", - "start" : "5MB", - "size" : "513MB", + "start" : "3MiB", + "size" : "203MiB", "boot" : True, "encrypted" : False, "format" : True, @@ -132,26 +171,33 @@ def suggest_multi_disk_layout(block_devices, default_filesystem=None, advanced_o "format" : "fat32" } }) + + if has_uefi(): + layout[root_device.path]['partitions'][-1]['start'] = '1MiB' + layout[root_device.path]['partitions'][-1]['size'] = '512MiB' + layout[root_device.path]['partitions'].append({ # Root "type" : "primary", - "start" : "518MB", + "start" : "206MiB", + "size" : "100%", "encrypted" : False, "format" : True, - "size" : "100%", "mountpoint" : "/", "filesystem" : { "format" : default_filesystem } }) + if has_uefi(): + layout[root_device.path]['partitions'][-1]['start'] = '513MiB' layout[home_device.path]['partitions'].append({ # Home "type" : "primary", + "start" : "1MiB", + "size" : "100%", "encrypted" : False, "format" : True, - "start" : "5MB", - "size" : "100%", "mountpoint" : "/home", "filesystem" : { "format" : default_filesystem |