From 62c28bc6d8c54800b16341d1c93a1d7833fc3328 Mon Sep 17 00:00:00 2001 From: Ryan Sundberg Date: Sat, 10 Jan 2026 13:35:31 -0800 Subject: [PATCH] image: Use `unshare` to map root user for btrfs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current version of `mkfs.btrfs` has a regression when combined with `fakeroot` where it does not detect the faked root uid/gid of files when building the filesystem. This produces partition images with `/` owned by the guixbuild user when it should be owned by root. Using `unshare` rather than `fakeroot` resolves this by doing the uid mapping at the kernel level rather than overloading the `stat` function. An equivalent issue was [reported and patched in NixOS](https://github.com/NixOS/nixpkgs/pull/434122) * gnu/build/image.scm (system-disk-image): Import `util-linux` instead of `fakeroot`. * gnu/system/image.scm (make-btrfs-image): Use `unshare --map-root-user` Change-Id: Id4eeaf510f3ec5f4a23b4d700a73e2cf46da40b1 Signed-off-by: Ludovic Courtès Merges: #5536 --- gnu/build/image.scm | 3 ++- gnu/system/image.scm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gnu/build/image.scm b/gnu/build/image.scm index 53c75839bab92ebfbdfeb6487c6c124f7824367f..dbb87103dafeabae4b7dc12f1606e972c69fcfe7 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -83,7 +83,8 @@ turn doesn't take any constant overhead into account, force a 1-MiB minimum." (label (partition-label partition)) (uuid (partition-uuid partition))) (apply invoke - `("fakeroot" "mkfs.btrfs" "-r" ,root + `("unshare" "--map-root-user" "mkfs.btrfs" + "-r" ,root "-L" ,label ,@(if uuid `("-U" ,(uuid->string uuid)) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 73686023a92e6a02df363a175f7a185d9e36df4d..ac0706aa0f1e1f3e57fee513af59a079bb9a0395 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -504,7 +504,7 @@ used in the image." initialize-root-partition)) (inputs '#+(cond ((string=? type "btrfs") - (list btrfs-progs fakeroot)) + (list btrfs-progs util-linux)) ((string-prefix? "ext" type) (list e2fsprogs fakeroot)) ((string=? type "f2fs")