Fix partition layout (#794)
* Fix partition layout * Tweaked the numbers to match the alignment of previous partitions. Co-authored-by: Anton Hvornum <anton.feeds@gmail.com>
This commit is contained in:
parent
762cea1da8
commit
08d7375e62
|
|
@ -6,6 +6,7 @@ if TYPE_CHECKING:
|
||||||
from .blockdevice import BlockDevice
|
from .blockdevice import BlockDevice
|
||||||
|
|
||||||
from .helpers import sort_block_devices_based_on_performance, select_largest_device, select_disk_larger_than_or_close_to
|
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
|
from ..output import log
|
||||||
|
|
||||||
def suggest_single_disk_layout(block_device :BlockDevice,
|
def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
|
|
@ -16,7 +17,7 @@ def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
from ..user_interaction import ask_for_main_filesystem_format
|
from ..user_interaction import ask_for_main_filesystem_format
|
||||||
default_filesystem = ask_for_main_filesystem_format(advanced_options)
|
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_subvolumes = False
|
||||||
using_home_partition = False
|
using_home_partition = False
|
||||||
|
|
||||||
|
|
@ -30,11 +31,19 @@ def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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({
|
layout[block_device.path]['partitions'].append({
|
||||||
# Boot
|
# Boot
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "5MB",
|
"start" : "3MiB",
|
||||||
"size" : "513MB",
|
"size" : "203MiB",
|
||||||
"boot" : True,
|
"boot" : True,
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
"format" : True,
|
"format" : True,
|
||||||
|
|
@ -43,10 +52,18 @@ def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
"format" : "fat32"
|
"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({
|
layout[block_device.path]['partitions'].append({
|
||||||
# Root
|
# Root
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "518MB",
|
"start" : "206MiB",
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
"format" : True,
|
"format" : True,
|
||||||
"mountpoint" : "/",
|
"mountpoint" : "/",
|
||||||
|
|
@ -55,6 +72,9 @@ def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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:
|
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')
|
using_home_partition = input('Would you like to create a separate partition for /home? (Y/n): ').strip().lower() in ('', 'y', 'yes')
|
||||||
|
|
||||||
|
|
@ -65,7 +85,7 @@ def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
# Or the user doesn't want to create a separate partition for /home
|
# Or the user doesn't want to create a separate partition for /home
|
||||||
layout[block_device.path]['partitions'][-1]['size'] = '100%'
|
layout[block_device.path]['partitions'][-1]['size'] = '100%'
|
||||||
else:
|
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 default_filesystem == 'btrfs' and using_subvolumes:
|
||||||
# if input('Do you want to use a recommended structure? (Y/n): ').strip().lower() in ('', 'y', 'yes'):
|
# if input('Do you want to use a recommended structure? (Y/n): ').strip().lower() in ('', 'y', 'yes'):
|
||||||
|
|
@ -90,10 +110,10 @@ def suggest_single_disk_layout(block_device :BlockDevice,
|
||||||
layout[block_device.path]['partitions'].append({
|
layout[block_device.path]['partitions'].append({
|
||||||
# Home
|
# Home
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
|
"start" : f"{min(block_device.size, 20)}GiB",
|
||||||
|
"size" : "100%",
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
"format" : True,
|
"format" : True,
|
||||||
"start" : f"{min(block_device.size+0.5, 20.5)}GB",
|
|
||||||
"size" : "100%",
|
|
||||||
"mountpoint" : "/home",
|
"mountpoint" : "/home",
|
||||||
"filesystem" : {
|
"filesystem" : {
|
||||||
"format" : default_filesystem
|
"format" : default_filesystem
|
||||||
|
|
@ -115,8 +135,8 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice],
|
||||||
# https://www.reddit.com/r/btrfs/comments/m287gp/partition_strategy_for_two_physical_disks/
|
# 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/
|
# https://www.reddit.com/r/btrfs/comments/9us4hr/what_is_your_btrfs_partitionsubvolumes_scheme/
|
||||||
|
|
||||||
MIN_SIZE_TO_ALLOW_HOME_PART = 40 # Gb
|
MIN_SIZE_TO_ALLOW_HOME_PART = 40 # GiB
|
||||||
ARCH_LINUX_INSTALLED_SIZE = 20 # Gb, rough estimate taking in to account user desktops etc. TODO: Catch user packages to detect size?
|
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()
|
block_devices = sort_block_devices_based_on_performance(block_devices).keys()
|
||||||
|
|
||||||
|
|
@ -136,11 +156,13 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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({
|
layout[root_device.path]['partitions'].append({
|
||||||
# Boot
|
# Boot
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "5MB",
|
"start" : "3MiB",
|
||||||
"size" : "513MB",
|
"size" : "203MiB",
|
||||||
"boot" : True,
|
"boot" : True,
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
"format" : True,
|
"format" : True,
|
||||||
|
|
@ -149,26 +171,33 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice],
|
||||||
"format" : "fat32"
|
"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({
|
layout[root_device.path]['partitions'].append({
|
||||||
# Root
|
# Root
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
"start" : "518MB",
|
"start" : "206MiB",
|
||||||
|
"size" : "100%",
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
"format" : True,
|
"format" : True,
|
||||||
"size" : "100%",
|
|
||||||
"mountpoint" : "/",
|
"mountpoint" : "/",
|
||||||
"filesystem" : {
|
"filesystem" : {
|
||||||
"format" : default_filesystem
|
"format" : default_filesystem
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if has_uefi():
|
||||||
|
layout[root_device.path]['partitions'][-1]['start'] = '513MiB'
|
||||||
|
|
||||||
layout[home_device.path]['partitions'].append({
|
layout[home_device.path]['partitions'].append({
|
||||||
# Home
|
# Home
|
||||||
"type" : "primary",
|
"type" : "primary",
|
||||||
|
"start" : "1MiB",
|
||||||
|
"size" : "100%",
|
||||||
"encrypted" : False,
|
"encrypted" : False,
|
||||||
"format" : True,
|
"format" : True,
|
||||||
"start" : "5MB",
|
|
||||||
"size" : "100%",
|
|
||||||
"mountpoint" : "/home",
|
"mountpoint" : "/home",
|
||||||
"filesystem" : {
|
"filesystem" : {
|
||||||
"format" : default_filesystem
|
"format" : default_filesystem
|
||||||
|
|
|
||||||
|
|
@ -255,8 +255,8 @@ def perform_installation(mountpoint):
|
||||||
# Placing /boot check during installation because this will catch both re-use and wipe scenarios.
|
# Placing /boot check during installation because this will catch both re-use and wipe scenarios.
|
||||||
for partition in installation.partitions:
|
for partition in installation.partitions:
|
||||||
if partition.mountpoint == installation.target + '/boot':
|
if partition.mountpoint == installation.target + '/boot':
|
||||||
if partition.size <= 0.25: # in GB
|
if partition.size < 0.19: # ~200 MiB in GiB
|
||||||
raise archinstall.DiskError(f"The selected /boot partition in use is not large enough to properly install a boot loader. Please resize it to at least 256MB and re-run the installation.")
|
raise archinstall.DiskError(f"The selected /boot partition in use is not large enough to properly install a boot loader. Please resize it to at least 200MiB and re-run the installation.")
|
||||||
|
|
||||||
# if len(mirrors):
|
# if len(mirrors):
|
||||||
# Certain services might be running that affects the system during installation.
|
# Certain services might be running that affects the system during installation.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue