This is very nice, thank you!
I've tested it with qemu.
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Tested-by: Oliver Smith <ollieparanoid@postmarketos.org>
---
Noticed I had used a noreply email address. Revised to use an actual
email address people can reach me with.
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