Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHTV04 <53527582+HTV04@users.noreply.github.com>2022-01-07 04:55:51 -0500
committerGitHub <noreply@github.com>2022-01-07 09:55:51 +0000
commit08d7375e6298084166fc8a0902666956346549c6 (patch)
tree7d45d9283d4112557c069120802bac4d48cc9274
parent762cea1da8d3dcba7da257668cb694a00dc8774e (diff)
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>
-rw-r--r--archinstall/lib/disk/user_guides.py59
-rw-r--r--examples/guided.py4
2 files changed, 46 insertions, 17 deletions
diff --git a/archinstall/lib/disk/user_guides.py b/archinstall/lib/disk/user_guides.py
index b0a8fe8a..a90ac506 100644
--- a/archinstall/lib/disk/user_guides.py
+++ b/archinstall/lib/disk/user_guides.py
@@ -6,6 +6,7 @@ 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 :BlockDevice,
@@ -16,7 +17,7 @@ def suggest_single_disk_layout(block_device :BlockDevice,
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
@@ -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({
# Boot
"type" : "primary",
- "start" : "5MB",
- "size" : "513MB",
+ "start" : "3MiB",
+ "size" : "203MiB",
"boot" : True,
"encrypted" : False,
"format" : True,
@@ -43,10 +52,18 @@ def suggest_single_disk_layout(block_device :BlockDevice,
"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" : "/",
@@ -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:
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
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'):
@@ -90,10 +110,10 @@ def suggest_single_disk_layout(block_device :BlockDevice,
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
@@ -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/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()
@@ -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({
# Boot
"type" : "primary",
- "start" : "5MB",
- "size" : "513MB",
+ "start" : "3MiB",
+ "size" : "203MiB",
"boot" : True,
"encrypted" : False,
"format" : True,
@@ -149,26 +171,33 @@ def suggest_multi_disk_layout(block_devices :List[BlockDevice],
"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
diff --git a/examples/guided.py b/examples/guided.py
index 0760baf1..e8a1f4df 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -255,8 +255,8 @@ def perform_installation(mountpoint):
# Placing /boot check during installation because this will catch both re-use and wipe scenarios.
for partition in installation.partitions:
if partition.mountpoint == installation.target + '/boot':
- if partition.size <= 0.25: # in GB
- 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.")
+ 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 200MiB and re-run the installation.")
# if len(mirrors):
# Certain services might be running that affects the system during installation.