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
Initrd improvements #97145
Initrd improvements #97145
Conversation
friendly ping |
@xaverdh sorry for the delays and thanks for the ping! So, I've revamped it. It should now:
The missing pieces are:
EDIT: I would also welcome if you could give this a spin with cross-compilation, I don't currently have a device handy on which I can try this. cc @elseym who expressed interest in this @ofborg build nixosTests.initrd-secrets |
First of all thanks for working on this!
Stupid question, did you try with a recent enough kernel (i.e. |
Good catch! Using |
Ok, so I now actually read the bash code in |
I believe the kernel will handle multiple concatenated and compressed files. At least this seems to be the case for most of the formats. However, I'm a lot more confused that grub seems to be giving the kernel two initramfs files… |
I have not verified this assumption, so sorry if I'm wrong. Wouldn't there be no differences between a "pre-appended" initramfs file ( |
I can imagine there would be other ways for a bootloader to give the kernel multiple initramfses than concatenating them. |
Right, so it turns out that the boot menu generation scripts for grub do indeed generate a second, otherwise empty initramfs. How exactly grub passes multiple initramfses still remains unclear to me. Meanwhile, the systemd-boot scripts do pre-concatenate the files to a single initramfs. Both approaches seem to work generally, lz4 and grub is the only combination that doesn't seem to work. |
I think the bootloader just passes the path via the kernel cmdline? And to pass several, you simply specify the option multiple times on the cmdline. At least that is how it works for early microcode loading if I remember correctly. |
There is no filesystem that the kernel is aware of at that point in time. You're being misled :). Here, in the list of parameters, there is confirmation:
[...]
For EFI stubs,
I added emphasis on the section explaining how it's not the kernel that is handling the |
I'd merge this after cleaning up the history, since it doesn't introduce any regressions AFAIU. Any opposition? |
Interesting, thanks for explaining! |
mips for example might use uImages too
IA64 (Itanium) is something completely different and certainly not what we want! x86_64 code lives in arch/x86 just like "classic" x86.
- Generate a link to the initramfs file with an appropriate file extension, guessed based on the compressor by default - Use correct metadata in u-boot images if generated, up to now this was hardcoded to gzip and would silently generate an erroneous image if another compressor was specified - Document all the parameters - Improve cross-building compatibility, by allowing passing either a string as before, or a function taking a package set and returning the path to a compressor in the "compressor" argument of the function. - Support more compression algorithms - Place compressor executable function and arguments in passthru, for reuse when appending initramfses Co-Authored-By: Dominik Xaver Hörl <hoe.dom@gmx.de>
lz4 compression is excluded because it doesn't work for a reason which remains unclear to me.
c15df3d
to
3136e49
Compare
Will merge tomorrow, unless anybody has any objections (including wanting to review beforehand, but not having the time). @ofborg build nixosTests.initrd-secrets nixosTests.boot |
For what its worth, I did some basic testing and this is actually backwards compatible to some degree (i.e. if the compressor is not just an executable but includes arguments), not sure if that's intentional but nice anyway. I can't efficiently test cross sadly :-/ I have two nits concerning the documentation though:
Anyway these not important points, so feel free to merge from my side. |
fully ;)
good point, this should be docbook. Will fix!
Yes. |
How's this? |
much better :) |
@@ -83,7 +83,7 @@ rec { | |||
if final.isAarch32 then "arm" | |||
else if final.isAarch64 then "arm64" | |||
else if final.isx86_32 then "x86" | |||
else if final.isx86_64 then "ia64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wat! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for reviewing a merged PR, but it appears to be the most convenient way to hilight an issue.
|
||
if [ -n "$makeUInitrd" ]; then | ||
mv $out/initrd $out/initrd.gz | ||
mkimage -A arm -O linux -T ramdisk -C gzip -d $out/initrd.gz $out/initrd | ||
mkimage -A $uInitrdArch -O linux -T ramdisk -C "$uInitrdCompression" -d $out/initrd"$extension" $out/initrd.img |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$uInitrdCompression
is not set here due to bad name in make-initrd.nix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$out/initrd"$extension"
cannot exist because the initrd is written without extension?
|
||
builder = ./make-initrd.sh; | ||
${if makeUInitrd then "uinitrdCompression" else null} = uInitrdCompression; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unitrdCompression
is not camelcased
# Compatibility symlink | ||
ln -s "initrd.img" "$out/initrd" | ||
else | ||
ln -s "initrd" "$out/initrd$extension" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(unrelated) Other way around makes more sense (i.e. compressor suffixed file) with initrd as symlink
Motivation for this change
initrd
is still provided for compatibility);makeInitrd
from one of the predefined platforms (likeaarch64-multiplatform
) can be significantly more convenient than defining a whole new platform — so this makes u-boot options available via the function call but optional, defaulting to the platform values;Closes #96005.
Things done
make-initrd.nix
itself, but not touched the relevant NixOS bits yet.