pmb.install: add support for creating btrfs root filesystem (MR 2155)

in preparation for reversible upgrades, this change adds the option of
creating a btrfs root filesystem
This commit is contained in:
Marian Stramm 2022-01-03 01:39:12 +01:00 committed by Alexey Min
parent 9e63d5820c
commit 80c988236f
No known key found for this signature in database
GPG Key ID: EBF5ECFFFEE34DED
3 changed files with 8 additions and 2 deletions

View File

@ -164,7 +164,8 @@ locales = [
]
# Supported filesystems and their fstools packages
filesystems = {"ext2": "e2fsprogs",
filesystems = {"btrfs": "btrfs-progs",
"ext2": "e2fsprogs",
"ext4": "e2fsprogs",
"f2fs": "f2fs-tools",
"fat16": "dosfstools",

View File

@ -35,6 +35,9 @@ def format_and_mount_boot(args, boot_label):
elif filesystem == "ext2":
pmb.chroot.root(args, ["mkfs.ext2", "-F", "-q", "-L", boot_label,
device])
elif filesystem == "btrfs":
pmb.chroot.root(args, ["mkfs.btrfs", "-f", "-q", "-L", boot_label,
device])
else:
raise RuntimeError("Filesystem " + filesystem + " is not supported!")
pmb.chroot.root(args, ["mkdir", "-p", mountpoint])
@ -106,6 +109,8 @@ def format_and_mount_root(args, device, root_label, sdcard):
mkfs_root_args = mkfs_root_args + ["-N", "100000"]
elif filesystem == "f2fs":
mkfs_root_args = ["mkfs.f2fs", "-f", "-l", root_label]
elif filesystem == "btrfs":
mkfs_root_args = ["mkfs.btrfs", "-f", "-L", root_label]
else:
raise RuntimeError(f"Don't know how to format {filesystem}!")

View File

@ -162,7 +162,7 @@ def arguments_install(subparser):
# Other
group = ret.add_argument_group("other optional arguments")
group.add_argument("--filesystem", help="root filesystem type",
choices=["ext4", "f2fs"])
choices=["ext4", "f2fs", "btrfs"])
def arguments_export(subparser):