mobile-nixos icon indicating copy to clipboard operation
mobile-nixos copied to clipboard

init: Fix kexec condition in SwitchRoot

Open samueldr opened this issue 2 years ago • 1 comments

In #300 I "fixed" stage-0 by adding a switch to toggle between it being enabled and disabled in the recovery menu. That works as expected.

In 2a46962d7638f0120db4678a97e8dc87ed45d0c9 one can observe that the #will_kexec? method will use data that will only come from the choice made from the recovery interface. The @use_generation_kernel member is not set at any other point.

With ruby semantics, this means that the if is false, so unless you choose to boot using the recovery menu, it will never trigger kexec.

Why has this gone through this way? Most likely because my main testing target was configured so it always went to the recovery menu at the time, meaning that I never saw the default behaviour.


TODO

  • [x] Determine why stage-0 doesn't work with the UEFI VM right now (in other word with nix-build ./examples/demo/ --argstr device uefi-x86_64 -A outputs.vm && ./result -smp 2

cc @betaboon, note that this will not fix the other problem you had, but fixes the observation that kexec was never used while it should have been.

samueldr avatar Jul 31 '22 20:07 samueldr

Not enough RAM to kexec in the UEFI VM apparently...

--- a/devices/uefi-x86_64/default.nix
+++ b/devices/uefi-x86_64/default.nix
@@ -13,7 +13,7 @@
       width = 720;
       height = 1280;
     };
-    ram = 1024 * 2;
+    ram = 1024 * 4;
   };
 
   boot.kernelParams = [

Which isn't a good look. The failure seems to imply that the kexec tooling will happily splat things in memory where things can't fit, and launch the next system, which in turn will (seemingly) have a truncated ramdisk...

[    0.410616] Initramfs unpacking failed: junk within compressed archive
bootlogd: error while loading shared libraries: libutil.so.1: cannot open shared object file: No such file or directory

Note that the exact errors are not always the same. So I suspect there really is a problem with memory being cut off or trampled on. They always can be attributed to "ramdisk is somewhat broken" though.

¯\_(ツ)_/¯

samueldr avatar Jul 31 '22 20:07 samueldr