Add cross-compilation support for disk formatting (ZFS)#1190
Add cross-compilation support for disk formatting (ZFS)#1190dvaerum wants to merge 1 commit intonix-community:masterfrom
Conversation
|
@DavHau can you take a look at this? |
789ab9f to
4c51c0c
Compare
|
Hey @Enzime, I am open for feedback, but this is a draft because it is not ready 😅 |
8980f86 to
25ca103
Compare
36699f9 to
b7163aa
Compare
When formatting disks for a different target architecture (e.g., creating an aarch64 disk image from an x86_64 host), tools like ZFS that communicate with kernel modules must use host-native binaries. I am guessing there also exist other cases when ZFS comes into play. This is not a problem with tools like `ext4` because they do everything in user space. I have created an example file and used it to build the file system for the archs `aarch64`, `armv7l`, `i686`, `riscv64` and `x86_64`. **Note:** The host system must have the following nixos configs enabled. ```nix # `preferStaticEmulators` is need or the activation script in chroot # cannot be executed because it is a different arch when the host system boot.binfmt.preferStaticEmulators = true; boot.binfmt.emulatedSystems = [ "<TARGET_ARCH>" ]; ```
|
This does make sense. We should always be able to format drives using local arch binaries, because the output is a formatted disk where to put stuff on. I mean, I can format any USB in any computer and, later, plug it in another one; it's just the same. I miss some docs about how to use the feature. |
What type of documentation are you looking for? Because the point is that you just use disko as you do now, it is just that the cross-building with ZFS (and hopefully by extension other other filesystems which uses kernel modules) setups also works. The change makes disko use the native binaries instead of emulating the binaries from another architecture. You do have to have the following enabled/configured on the system you run disko on (but you always need that for cross-build). { boot.binfmt.preferStaticEmulators = true;
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
}I have just added a check with an error message, as you can see here. |
Add cross-compilation support for disk formatting (ZFS)
When formatting disks for a different target architecture (e.g.,
creating an aarch64 disk image from an x86_64 host), tools like ZFS that
communicate with kernel modules must use host-native binaries.
I am guessing there also exist other cases when ZFS comes into play.
This is not a problem with tools like
ext4because they do everythingin user space.
I have created an example file and used it to build the file system for
the archs
aarch64,armv7l,i686,riscv64andx86_64.Note: The host system must have the following nixos configs enabled.
Update: 2026-03-04
If you get the following error when trying out this patch:
When it happens because the disko version used in your flake input of the system you are trying to build is from upstream. You need to use this for your flake inputs:
I just bumped into this problem today and was quite confused for some time.