~postmarketos/pmbootstrap-devel

pmbootstrap: install: initial implementation of flat btrfs layout v1 SUPERSEDED

~papiris: 1
 install: initial implementation of flat btrfs layout

 2 files changed, 25 insertions(+), 2 deletions(-)
#1126322 .build.yml failed
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/48268/mbox | git am -3
Learn more about email & git

[PATCH pmbootstrap] install: initial implementation of flat btrfs layout Export this patch

From: papiris <75946143+ruzko@users.noreply.github.com>

---
This draft patchset makes btrfs subvolumes for home, root and var;
separate from the top level (filesystem) subvolume.
The aim is to make it possible to rollback to a working state,
if the pmOS system gets borked somehow.

# Related issues
- https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2280
- https://gitlab.com/postmarketOS/pmaports/-/issues/492


# Caveats
- CI doesn't work on my dev machine or my pmos edge phone,
even on the main pmbootstrap branch,
so I've not had a chance to run this patch through CI.
- Although /home and /var subvolumes get properly mounted,
/root does not get mounted as /.

I welcome your guidance :)
Happy new year!

 pmb/install/_install.py | 20 ++++++++++++++++++--
 pmb/install/format.py   |  7 +++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/pmb/install/_install.py b/pmb/install/_install.py
index 1adfe789..35020375 100644
--- a/pmb/install/_install.py
+++ b/pmb/install/_install.py
@@ -152,8 +152,12 @@ def create_home_from_skel(args):
    Create /home/{user} from /etc/skel
    """
    rootfs = args.work + "/chroot_native/mnt/install"
    if args.filesystem == "btrfs":
        pmb.helpers.run.root(args,
        ["btrfs", "subvol", "create", rootfs + "/home"])
    else:
        pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
    homedir = rootfs + "/home/" + args.user
    pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
    if os.path.exists(f"{rootfs}/etc/skel"):
        pmb.helpers.run.root(args, ["cp", "-a", f"{rootfs}/etc/skel", homedir])
    else:
@@ -757,7 +761,19 @@ def create_fstab(args, layout, suffix):
    boot_filesystem = args.deviceinfo["boot_filesystem"] or "ext2"
    root_filesystem = pmb.install.get_root_filesystem(args)

    fstab = f"""
    if root_filesystem == "btrfs":
        # btrfs gets separate subvolumes for root, var and home
        fstab = f"""
# <file system> <mount point> <type> <options> <dump> <pass>
{root_mount_point} / {root_filesystem} subvol=root,compress=zstd:2,ssd 0 0
{root_mount_point} /home {root_filesystem} subvol=home,compress=zstd:2,ssd 0 0
{root_mount_point} /var {root_filesystem} subvol=var,compress=zstd:2,ssd 0 0

{boot_mount_point} /boot {boot_filesystem} defaults 0 0
""".lstrip()

    else:
        fstab = f"""
# <file system> <mount point> <type> <options> <dump> <pass>
{root_mount_point} / {root_filesystem} defaults 0 0
{boot_mount_point} /boot {boot_filesystem} defaults 0 0
diff --git a/pmb/install/format.py b/pmb/install/format.py
index 6eebd1c6..21cf0579 100644
--- a/pmb/install/format.py
+++ b/pmb/install/format.py
@@ -124,6 +124,13 @@ def format_and_mount_root(args, device, root_label, disk):
    pmb.chroot.root(args, ["mkdir", "-p", mountpoint])
    pmb.chroot.root(args, ["mount", device, mountpoint])

    # Create separate subvolumes if root filesystem is btrfs
    if filesystem == "btrfs":
        pmb.chroot.root(args,
            ["btrfs", "subvol", "create", mountpoint + "/root"])
        pmb.chroot.root(args,
            ["btrfs", "subvol", "create", mountpoint + "/var"])


def format(args, layout, boot_label, root_label, disk):
    """
-- 
2.38.5
pmbootstrap/patches/.build.yml: FAILED in 23s

[install: initial implementation of flat btrfs layout][0] from [~papiris][1]

[0]: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/48268
[1]: mailto:jacob.ludvigsen@protonmail.com

✗ #1126322 FAILED pmbootstrap/patches/.build.yml https://builds.sr.ht/~postmarketos/job/1126322