From: Daan De Meyer Date: Tue, 23 Jul 2024 20:36:55 +0000 (+0200) Subject: If the image is nocow, make the ephemeral copy nocow as well X-Git-Tag: v24~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b9ba32efbcb350e1340fda91566b2c7b1782ecc;p=thirdparty%2Fmkosi.git If the image is nocow, make the ephemeral copy nocow as well On btrfs, VM images are generally recommended to be made nocow as cow (copy-on-write) and random writes don't play well together. Let's take this into account in copy_ephemeral() and make the ephemeral copy nocow as well if the source is nocow. --- diff --git a/mkosi/qemu.py b/mkosi/qemu.py index e62db3f41..b6d3bb036 100644 --- a/mkosi/qemu.py +++ b/mkosi/qemu.py @@ -533,6 +533,19 @@ def copy_ephemeral(config: Config, src: Path) -> Iterator[Path]: def copy() -> None: if config.output_format == OutputFormat.directory: become_root() + elif config.output_format in (OutputFormat.disk, OutputFormat.esp): + attr = run( + ["lsattr", "-l", src], + sandbox=config.sandbox(binary="lsattr", mounts=[Mount(src, src, ro=True)]), + stdout=subprocess.PIPE, + ).stdout + + if "No_COW" in attr: + tmp.touch() + run( + ["chattr", "+C", tmp], + sandbox=config.sandbox(binary="chattr", mounts=[Mount(tmp, tmp)]), + ) copy_tree( src, tmp,