-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
RFC: Live environment with nix store included in initrd #14538
Comments
Maybe in this part:
instead of using |
Thanks for the work! I still have to give this a try, but this looks promising. Will try tomorrow. Also, related to #2100. |
I've made some changes. Squashfs now mounts, but Stage 2 cannot be started because it cannot find init. https://github.com/bobvanderlinden/nixpkgs/tree/cerana-test1 To build:
This results in the 3 files:
To run inside qemu:
In stage 1 it has The problem is (I think) that Not sure whether this is the case, but I couldn't figure it out yet. |
Yes, switch_root deleting everything in the initrd sounds correct (as in it should do that by design). But I think it shouldn't matter that the squashfs image gets deleted as accessing unlinked files that are already open should work just fine in Linux. Probably something else is amiss. |
@dezgeg Thanks for the tips, it was an incorrect path for the mountpoint :/ Anyway, it's now booting correctly in Qemu. Not sure whether it works the same for iPXE. |
The next phase I was going to work on was actually removing use of the squashfs and just putting the /nix contents directly into the initrd. @bobvanderlinden, do you think that would be possible? |
Not sure if that's worth the complexity of having extra code for something that's used really rarely. |
@nshalman I have thought of this as well. I'm not sure, it shortens the build time (creating squashfs + creating initrd takes a bit of IO), but it seems from reading online that squashfs is still efficient in initrd. That said, I gave it a short try, but due to I'd go for cleaning things up, de-branding the code and making it ready for inclusion in NixOS @dezgeg I agree that the extra complexity might not be worth it, but do not underestimate the usage of @nshalman's changes. Having a separate kernel+initrd will allow various types of iPXE/PXE booting. That will allow netboot.xyz support as well as somewhat proper support for cloud providers like Digital Ocean (no need for nixos-in-place or nixos-assimilate). |
Naming things is hard. Does anyone have suggestions of naming to use for removing the "cerana" stuff from the code? PXE or netboot are logical options, I guess. |
Even though it's just a standalone initrd, I guess |
@bobvanderlinden I have a de-branded version of this work in master...nshalman:netboot-v1 For my purposes I definitely need to do further work to see how easy it would be to eliminate the use of squashfs. I'm guessing that if built correctly my variant wouldn't need to ever invoke Testing of that netboot-v1 branch is very welcome. Further tweaks to it (e.g. moving the nouveau blacklisting from netboot.nix to netboot-minimal.nix) are also welcome. |
Nice. Also, don't worry about crediting. I tried to boot this today over iPXE in qemu, however I couldn't make it work. I haven't done much with iPXE before, so this might be a problem on my side. That said, it's worth checking whether it actually boots over the network.
It loads the kernel, it loads initrd into memory, it boots the kernel, it unpacks initrd, but then it fails on executing init with the following error:
The error seems different from "init not found", so I don't know what is happening atm. |
I've done some simple testing using the iPXE that is built into QEMU (see nshalman@e850edb) and it appears to work just fine. @bobvanderlinden please confirm that it works for you as my example demonstrates. |
Squashed down into master...nshalman:netboot-v2 I think this is nearly ready to be turned into a PR... |
Based on some testing, given how much of the nix store needs to live in the initrd anyway, I think that putting the nix store that ends up in the squashfs directly in the initrd will probably be a very effective way of further shrinking the final initrd size.
|
Yes, that might be a more efficient way. However, it isn't as easy as bind-mounting / to /mnt-root, since switch_root will delete everything from /. That said, I've added a boot-test for netboot: https://github.com/bobvanderlinden/nixpkgs/tree/netboot-v2 |
It's actually easier than I thought it would be. The essence of it is in the following change: nshalman@1ced0c9 We sidestep the need for stage1 by having /init be a link to the toplevel/stage2 init. A side effect of that is that the closure for the whole system ends up in the initrd so there's no need for the squashfs. I've squashed that change into a new branch which also includes @bobvanderlinden's test code (in its own commit for credit purposes 😉) which is here: master...nshalman:netboot-v3 Edit: Sorry for the false closure, accidentally hit the wrong button on the web page. |
And it's currently broken.. I've still got some work to do. |
Okay, there's something weird with trying to sidestep the squashfs that's complicated enough that I think it should be separate work, either follow-on for an official netboot, or just something I use downstream and not in the official version at all. |
Resolved by #14740 |
Issue description
I'm working on a new Linux based project that is currently using a different build system and I'm evaluating Nix as a replacement.
Our system runs mostly from a stripped down Linux image in memory that includes the full system in the initrd which makes it very very simple to boot with network booting. No need to fetch an additional squashfs (and it's practical because our image is so lean.) We then put a ZFS pool on the disks to use as storage for the workloads we run on the machines.
I've been flailing around (see master...nshalman:cerana-test1) trying to get something that works and coming up short.
I think Nix/NixOS is a very good project for us to collaborate with. A much more elegant version of what I've been working on is something that I'd want to get merged into nixpkgs so that we can collaborate further with NixOS.
The text was updated successfully, but these errors were encountered: