Netboot: Difference between revisions

Nh2 (talk | contribs)
Reduce build time of second example
Onny (talk | contribs)
Cleanup page
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Building and serving a netboot image ==
This provides an easy way to serve the NixOS installer over netboot, such as when you already have a working NixOS machine and want to install NixOS on a second machine connected to the same network.
This provides an easy way to serve the NixOS installer over netboot, such as when you already have a working NixOS machine and want to install NixOS on a second machine connected to the same network.


=== Example ===
== Setup ==
This example uses [https://github.com/danderson/netboot/tree/main/pixiecore Pixiecore] for hosting, which works in an ordinary network environment with an existing DHCP server.
This example uses [https://github.com/danderson/netboot/tree/main/pixiecore Pixiecore] for hosting, which works in an ordinary network environment with an existing DHCP server. Pixiecore will notice when the booted machine talks to the network's existing DHCP server, and send netboot information to it at that time.
{{Note|Your iPXE must be recent enough to support https:// links}}<syntaxhighlight lang="nix">
services.pixiecore = {
  enable = true;
  openFirewall = true;
  dhcpNoBind = true;
  kernel = "https://boot.netboot.xyz";
};


Pixiecore will notice when the booted machine talks to the network's existing DHCP server, and send netboot information to it at that time.
</syntaxhighlight>The Pixicore server will provide a [https://netboot.xyz netboot.xyz] multi-boot image to the clients, offering various operating systems which will get downloaded by the client on demand.


== Tips and tricks ==
=== Serve custom NixOS installation images ===
Create file <code>system.nix</code>:
Create file <code>system.nix</code>:
<syntaxHighlight lang=nix>
<syntaxhighlight lang="nix">let
let
   nixpkgs = builtins.getFlake "github:nixos/nixpkgs/nixos-25.11";
  # NixOS 22.11 as of 2023-01-12
   nixpkgs = builtins.getFlake "github:nixos/nixpkgs/54644f409ab471e87014bb305eac8c50190bcf48";


   sys = nixpkgs.lib.nixosSystem {
   sys = nixpkgs.lib.nixosSystem {
Line 46: Line 53:
   '';
   '';
in
in
   run-pixiecore
   run-pixiecore</syntaxhighlight>Building:<syntaxhighlight lang="bash">
</syntaxHighlight>Building:<syntaxhighlight lang="bash">
# Build pixiecore runner
# Build pixiecore runner
nix-build system.nix -o /tmp/run-pixiecore
nix-build system.nix -o /tmp/run-pixiecore
Line 64: Line 70:
</syntaxhighlight>
</syntaxhighlight>


=== Another example ===
==== Another example ====
{{file|netboot.nix|nix|3={
{{file|netboot.nix|nix|3={
   name ? "netboot",
   name ? "netboot",
Line 224: Line 230:
* Run the example exactly like the other example further up on the page.
* Run the example exactly like the other example further up on the page.


=== See also ===
=== Troubleshooting ===
NixOS: [https://search.nixos.org/options?type=packages&query=services.pixiecore Pixiecore module].
 
* Error "'''autoexec.ipxe... Operation not supported'''": See [https://github.com/NixOS/nixpkgs/pull/378513#pullrequestreview-3081586117 this issue].


NixOS manual: [https://nixos.org/nixos/manual/index.html#sec-booting-from-pxe PXE booting].
== See also ==


== netboot.xyz ==
* NixOS manual: [https://nixos.org/nixos/manual/index.html#sec-booting-from-pxe PXE booting].
There is now official [https://netboot.xyz/ netboot.xyz] support.
Just select <b>NixOS</b> from Linux installs and you should be ready to go.


<b>Note:</b> Your iPXE must be recent enough to support https:// links
[[Category:Booting]]
[[Category:Booting]]