New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Raspberry Pi 4B SD-Card Install Image #93824
Conversation
This fix should also make this Hydra job happy again: https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image_raspberrypi4.aarch64-linux/ |
I've verified that the resulting SD-Card image boots on my Raspberry Pi 4. 🍾 |
For me sudo didn't work any more. Could this possibly be because of this change? |
|
I'm cross-compiling on NixOS. What do you mean with single-user nix? Edit: I will retry - will take some time as I also garbage collected before to be safe. |
I had this issue when using https://nixos.org/nix/manual/#sect-single-user-installation on Ubuntu, that's why there is a |
As far as I understand https://git.qemu.org/?p=qemu.git;a=commit;h=d8c08b1e6c7b1a5be1ec70e339437823a41b1946 a new version of qemu might fix that and allow us to use fakeroot again? Also I consistently get an image file with invalid permissions inside (the ones from my user) with this pull request. |
@mohe2015 I also see subtle issues with building this from a multi-user install that I didn't notice before:
Mmh. I think this can be fixed by using
Will try this later. Converting this PR to a draft until then to prevent people from merging it. :) |
I couldn't get it to work with the root_owner option. I think it's result is the following: [moritz@nixos:~/nixpkgs]$ ls -l /run/media/moritz/
total 8
drwxr-xr-x 3 moritz users 4096 Jan 1 1970 NIXOS_BOOT
drwxr-xr-x 4 root root 4096 Jan 1 1970 NIXOS_SD
[moritz@nixos:~/nixpkgs]$ ls -l /run/media/moritz/NIXOS_SD/
total 236
drwx------ 2 root root 16384 Jan 1 1970 lost+found
drwxr-xr-x 3 moritz users 4096 Jan 1 1970 nix
-r--r--r-- 1 moritz users 217404 Jan 1 1970 nix-path-registration So the root directory is owned by the specified user but not the files in it. Maybe I did something wrong so you should still try it out. Edit: Updating qemu to 5.1.0-rc1 and using fakeroot did work but I don't know if that change would currently be accepted (as it is not yet a stable release; see https://wiki.qemu.org/Planning/5.1 for their current plans) |
@mohe2015 You are right, the |
@mohe2015 I'm not sure how we ever end up with sane uid/gids using In the build sandbox the nixbld user is 1000:100, but outside of the sandbox this is usually the uid/gid of the first user in the system. Hence we get the broken owners in the image. Ideally, I'm open to ideas... |
For me it worked by building with qemu 5.1.0-rc1 and using fakeroot. At least sudo worked and I couldn't find something nonworking. But there still were some strange file permissions in there. |
Ah, because fakeroot makes |
Yeah, I think the problem is that running |
Yes, that's also my current understanding. Not an ideal situation. |
c36cfc1
to
13bb122
Compare
I've added the |
I think you need to also add back fakeroot in two other places. And also do you know more whether qemu 5.1.0-rc1 would be accepted in nixpkgs unstable? I assume I will have to wait for the release until it gets incoporated here but I don't know. |
13bb122
to
9c942bc
Compare
You were too fast, I fixed it right after @GrahamcOfBorg complained. :)
The binfmt emulation is pretty nice and having it fail in weird ways definitely sucks. No idea whether this counts as good reason to include a RC into unstable. Btw, with the current version of this PR and qemu 5.1-rc1 on the build host, I can build a SD Card image that works. Finally! |
In 9ac1ab1 this library function was refactored to use mkfs.ext4 instead of cptofs. There are two problems: If populateImageCommands would create no files (which is fine), a cp invocation would fail due to missing source arguments. Another problem is that mkfs.ext4 relies on fakeroot to have sane uid/gids in the generated filesystem image. This currently doesn't work for cross compiling.
9c942bc
to
fd2047c
Compare
Thanks for this fix -- I ran into this breakage locally and this worked like a charm. |
As the pr became quite uncontroversial now, i would merge this in the next days if no one objects. |
FWIW, the Debian maintainers decided to backport the QEMU fix @mohe2015 mentioned in their stable QEMU 5.0 package (original issue). Perhaps we can reuse the same patch and apply it on top of the current QEMU 5 package in |
In the meantime, is this ready to merge @tfc? I just got a Raspberry Pi 4B in the mail, and I'm hyped 👀 |
In 9ac1ab1 / #82718 make-ext4-fs was refactored to use mkfs.ext4 instead of cptofs. This introduced a problem:
invocation would fail due to missing source arguments.
Note that
mkfs.ext4
relies onfakeroot
to generate sane uids/gids and this currently fails when using theaarch64-linux
binfmt emulation on x86.I've used the following command for testing:
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)