1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-23 04:25:10 +03:00

WIP: install: rootless disk image

Refactor the install code to stop using loop devices and instead create
and manipulate a disk image directly. Both ext4 and vfat have mechanisms
for formatting and populating partitions at an offset inside an image,
other filesystems likely do as well but so far have not been implemented
or tested.

With this "pmbootstrap install" works for standard EFI disk images (e.g.
QEMU, X64 or trailblazer) entirely rootless.

Since the creation of the disk images happens in the same user namespace
as everything else, the resulting disk images have correct ownership and
permissions even though from the host perspective they are all subuids.

This gets image building working properly *for the default case*. We can
now build disk images! In particular, we can build disk images with a 4k
sector size even on a host with a 512 byte sector size (or block size in
the filesystem). This is surprisingly hard for some reason since not all
libfdisk tools have the right flags. Thankfully sfdisk does.

In addition, we now generate UUIDs ourselves, to break the loop between
generating fstab and running mkfs (since we also populate the disk image
/with/ mkfs, we need to already know the UUID when we run it...).

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
This commit is contained in:
Casey Connolly 2025-05-08 17:23:32 +02:00
parent 9a6e32fb6d
commit ecf1d54e39
20 changed files with 541 additions and 500 deletions

View file

@ -5,8 +5,10 @@
import pmb.parse.deviceinfo
from pmb import commands
from pmb.core.context import get_context
from pmb.core.chroot import Chroot
from pmb.flasher.frontend import flash_lk2nd, kernel, list_flavors, rootfs, sideload
from pmb.helpers import logging
import pmb.chroot
class Flasher(commands.Command):
@ -39,6 +41,9 @@ class Flasher(commands.Command):
logging.info("This device doesn't support any flash method.")
return
# Ensure the chroot is ready
pmb.chroot.init(Chroot.native())
if action in ["boot", "flash_kernel"]:
kernel(
deviceinfo,