pmb/install: Add option to create single combined boot/root partition

With recent rework in postmarketos-initramfs, we no longer need to mount
the /boot partition in the initramfs (assuming initramfs-extra is not
used). On devices that boot without accessing the boot file system (e.g.
Android boot images, fastboot, ...), that makes it possible to install
postmarketOS on a single (potentially encrypted) partition that contains
both root (/) and /boot files.

This avoids the extra complexity of the subpartition setup we usually use
on such devices, and also avoids having to flash two partitions (when using
--split to avoid the subpartitions).

Add a --single-partition option to pmbootstrap install that allows
installing postmarketOS in this mode. For now this is just an option that
must be selected explicitly, in the future we could choose to make this the
default for Android-based devices with a large enough boot partition.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2512
This commit is contained in:
Stephan Gerhold 2024-11-22 11:45:33 +01:00 committed by Oliver Smith
parent ec0163ce63
commit e9038e50d6
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 88 additions and 38 deletions

View file

@ -205,23 +205,28 @@ def format_and_mount_root(
def format(
args: PmbArgs,
layout: PartitionLayout,
layout: PartitionLayout | None,
boot_label: str,
root_label: str,
disk: PathString | None,
) -> None:
"""
:param layout: partition layout from get_partition_layout()
:param layout: partition layout from get_partition_layout() or None
:param boot_label: label of the boot partition (e.g. "pmOS_boot")
:param root_label: label of the root partition (e.g. "pmOS_root")
:param disk: path to disk block device (e.g. /dev/mmcblk0) or None
"""
root_dev = f"/dev/installp{layout['root']}"
boot_dev = f"/dev/installp{layout['boot']}"
if layout:
root_dev = f"/dev/installp{layout['root']}"
boot_dev = f"/dev/installp{layout['boot']}"
else:
root_dev = "/dev/install"
boot_dev = None
if args.full_disk_encryption:
format_luks_root(args, root_dev)
root_dev = "/dev/mapper/pm_crypt"
format_and_mount_root(args, root_dev, root_label, disk)
format_and_mount_boot(args, boot_dev, boot_label)
if boot_dev:
format_and_mount_boot(args, boot_dev, boot_label)