Skip to content
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

Add netboot files #21

Closed
wants to merge 3 commits into from
Closed

Add netboot files #21

wants to merge 3 commits into from

Conversation

lheckemann
Copy link
Member

Allows adding nixos support to netboot.xyz (netbootxyz/netboot.xyz#37). NOT TESTED. Depends on NixOS/nixpkgs#43805. Fixes #6

Also fixes building the scripts on the side.

cc @fpletz @domenkozar @nshalman @matthewbauer who have expressed interest in netboot.xyz support

@lheckemann
Copy link
Member Author

Update: I don't think this will work correctly either, since the component derivations' outputs are also directories rather than individual files 🤦‍♂️

@edolstra
Copy link
Member

That's not a problem as long as the derivation emits a hydra-build-products file (similar to the ISO image jobs).

@lheckemann
Copy link
Member Author

Yes, I realised this earlier. However, since A) these derivations aren't actually hydra jobs and B) the netboot files are symlinks (NixOS/hydra#580), this doesn't work yet.

This allows testing channel mirroring locally without access to S3
@lheckemann
Copy link
Member Author

Fixed! Things to note:

@edolstra
Copy link
Member

Some questions:

  • How will netboot.xyz find these files?

  • What filename are they uploaded to? I gather it's {netboot.ipxe,initrd,bzImage}. In that case they should really be put in a subdirectory since having files names initrd or bzImage is not very informative.

  • I gather from NixOS support netbootxyz/netboot.xyz#37 that netboot.xyz can use ISOs directly. That would be much preferred to adding yet another big image to our release process. Why can't we do that?

  • In https://hydra.nixos.org/build/79499085 I see a 440 MiB initrd, which seems rather big for an initrd. Does it contain the entire Nix store or something? Doesn't that require the entire initrd to be decompressed into memory?

Aside: the ideal netboot would be to have a minimal initrd that mounts cache.nixos.org on /nix/store (via NixOS/nix@a9cbd67) and boots the system closure from there.

@lheckemann
Copy link
Member Author

How will netboot.xyz find these files?

After this, they should be available at https://nixos.org/channels/nixos-{18.03,unstable}/netboot.ipxe.

What filename are they uploaded to? I gather it's {netboot.ipxe,initrd,bzImage}. In that case they should really be put in a subdirectory since having files names initrd or bzImage is not very informative.

That makes sense, I can try doing that.

I gather from netbootxyz/netboot.xyz#37 that netboot.xyz can use ISOs directly. [snip] Why can't we do that?

It's unable to find the root filesystem, for reasons similar to boot failures caused by incorrect USB stick creation.

much preferred to adding yet another big image to our release process

These files are already built by hydra, does including them on the channel page make a big difference?

Does it contain the entire Nix store or something? Doesn't that require the entire initrd to be decompressed into memory?

Yes and no respectively. It contains the entire nix store as a squashfs (much like the CD image), which is mounted and decompressed on the fly.

Aside: the ideal netboot would be to have a minimal initrd that mounts cache.nixos.org on /nix/store (via NixOS/nix@a9cbd67) and boots the system closure from there.

That is awesome! Orthogonal to this change, but it should allow making the initrd a bit smaller in future versions.

@Mic92
Copy link
Member

Mic92 commented Oct 18, 2018

ping @lheckemann

@Mic92
Copy link
Member

Mic92 commented Jan 14, 2019

zram and zstd might help with the size: NixOS/nixpkgs#52991

@danbst
Copy link

danbst commented Jan 14, 2019

@Mic92 current zramSwap module isn't designed to be started in stage1. Also, if that squashfs @lheckemann mentions is already compressed, then it can't be compressed more, and thus no extra memory gain.

@Mic92
Copy link
Member

Mic92 commented Jan 16, 2019

This snippet by @Lassulus would download the iso in the initrd:

{ pkgs, lib }: let
  system = import <nixpkgs/nixos/lib/eval-config.nix> {
    modules = [{
      imports = [
        <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix>
      ];
      boot.initrd.network.enable = true;
      boot.devSize = "500m";
      boot.initrd.kernelModules = [ "e1000" ];
      boot.initrd.extraUtilsCommands =''
        cp ${pkgs.stdenv.cc.libc}/lib/libnss_dns.so.* $out/lib/
      '';
      boot.initrd.network.postCommands = ''
        wget 'https://d3g5gsiof5omrk.cloudfront.net/nixos/18.09/nixos-18.09.1922.97e0d53d669/nixos-minimal-18.09.1922.97e0d53d669-x86_64-linux.iso' -O /dev/root
      '';
      boot.initrd.postMountCommands = ''
        export stage2Init=$(awk '/APPEND/ {for(i=1;i<=NF;i++){ if($i ~ /init/){split($2,a,"="); print a[2]; exit} } }' /mnt-root/iso/isolinux/isolinux.cfg)
      '';
    }];
  };
in pkgs.writeScript "run" ''
  #!/bin/sh
  ${pkgs.kvm}/bin/qemu-kvm -m 2G \
    -kernel ${system.config.system.build.kernel}/bzImage \
    -initrd ${system.config.system.build.initialRamdisk}/initrd \
    -net nic,netdev=user.0,model=e1000 -netdev user,id=user.0,hostfwd=tcp::8022-:22 \
    -append "console=ttyS0 copytoram" -nographic
''

@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/easy-to-use-nixos-image-generators/1887/4

@JohnAZoidberg
Copy link
Member

Do the images that netboox.xyz uses work?
Is it enough to have netbook fetch them from Hydra? Wouldn't it be nice to have it in the channel?

That doesn't finish for me, even after a few minutes:

$ wget https://hydra.nixos.org/job/nixos/trunk-combined/nixos.netboot.x86_64-linux/latest-finished/download/netboot.ipxe
--2019-07-04 23:04:11--  https://hydra.nixos.org/job/nixos/trunk-combined/nixos.netboot.x86_64-linux/latest-finished/download/netboot.ipxe
Resolving hydra.nixos.org (hydra.nixos.org)... 46.4.67.10, 2a01:4f8:140:248f::
Connecting to hydra.nixos.org (hydra.nixos.org)|46.4.67.10|:443... connected.
HTTP request sent, awaiting response... 

@Lassulus
Copy link
Member

Lassulus commented Jul 4, 2019

I just tested it inside a qemu VM, the unstable channel image works, even though the wget also does nothing for me.
Would still be nice to have the netboot stuff in the channel to have it on a faster server. But as long as it works I'm happy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NixOS channels: copy also PXE boot files
7 participants