mardi 5 avril 2016

nixos 16.03 live iso boot "directly" from grub

I hate extracting iso images. I prefer to run them through grub loopback. Nixos 16.03 release is a few days old, I couldn't resist. Alas, booting it this way drops me in a rescue shell.

The initrd is set up to only have one layer of virtual fs. So it assumes the squashfs nix-store would be in /mnt-root/iso and complains since it is not.

So after trying to MITM myself and mount the desired FS where they should be, I replicate the final steps of the nixos initrd init script. Kernel panic.

I'm dumbfounded, I need to be more thorough. The init scripts reads a fsinfo file (fstab-like in a different format say) to prepare the new root for the real stage 2 kernel.

btw, my mistake was to simply mount the nix-store squashfs file in /mnt-root/nix/.ro-store and then symlink /mnt-root/nix/store to it. It works only partially as the stage2 kernel find its init and proceed to run systemd but hangs after a few services doing nothing. Only option: CTRL-ALT-DEL. (I even tried to instrument stage2 systemd into booting the rescue target, hoping for a rescue shell to investigate the hang .. no luck). Then I realize that the fsinfo mounts the squashfs in nix/.ro-store BUT, also prepares a unionfs in nix/store ! Maybe stage2 is waiting for a unionfs mount in nix/store and my symlink is confusing things up.

So I insert the missing layer in there. And just sh /init. It fails horribly saying 'cannot stop udev/queue' then 'Killed'. Not thrilled.

I extract the final steps of the init script (populate /mnt-root with proc,sys,run,dev; kill a few things; restore the path for `modprobe` in the new /proc/sys/kernel/modprobe value). And then exec switch_root ...

I can now enjoy nixos 16.03 live booting directly from grub. If you allow directly to allow user intervention .. heh.

Aucun commentaire:

Enregistrer un commentaire