13 feb 2016
intel PXE is used to boot a computer by using the network as source for the OS. this posting is about how to do that with NixOS.
mount the ISO and copy:
to the http-root
mount iso /mnt/root
cd `mktemp -d`
zcat /mnt/root/boot/initrd |cpio -i
mkdir mnt
# now we do squashfs nesting (just a hack)
mksquashfs /mnt/root/nix-store.squashfs mnt/nix.squashfs
find . | cpio --create --format='newc' >/srv/http/initrd+squash_mnt-root_iso.gz
#!ipxe
dhcp
kernel http://10.0.0.1/bzImage init=/nix/store/mafzr4bbsdz8wxz842407xmp4x964k6n-nixos-15.09.784.7b85b8a/init root=/mnt/nix-root.squashfs boot.shell_on_fail nomodeset loglevel=7 initrd=initrd+squash_mnt-root_iso.gz
initrd http://10.0.0.1/initrd+squash_mnt-root_iso.gz
boot
EOF
#!ipxe
dhcp
kernel http://10.0.0.1/efi.img init=/nix/store/mafzr4bbsdz8wxz842407xmp4x964k6n-nixos-15.09.784.7b85b8a/init root=/mnt/nix-root.squashfs boot.shell_on_fail nomodeset loglevel=7 initrd=initrd+squash_mnt-root_iso.gz
initrd http://10.0.0.1/initrd+squash_mnt-root_iso.gz
boot
EOF
this configures dhcp / pxe
interface=br0
# Important Note: the 'set:' and 'tag:!ipxe' syntax requires dnsmasq 2.53 or above.
dhcp-match=set:ipxe,175 # iPXE sends a 175 option.
# load undionly.kpxe for clients not tagged with 'ipxe'.
dhcp-boot=tag:!ipxe,undionly.kpxe
# undionly.kpxe issues a second DHCP request and we then serve bootstrap.ipxe over http
# using Robin Smidsrød's bootstrap method provided at https://gist.github.com/2234639
dhcp-boot=http://10.0.0.1/bootstrap.ipxe
# Or, simply load your own menu
# dhcp-boot=menu.ipxe
dhcp-range=10.0.0.4,10.0.0.50
dhcp-option=option:dns-server,10.0.0.1
dhcp-option=option:router,10.0.0.1
#dhcp-option=option:domain-search,demo.lihas.de
#dhcp-option=option:domain-name,demo.lihas.de
dhcp-option=option:ntp-server,10.0.0.1
dhcp-option=19,0
dhcp-option=44,10.0.0.1
dhcp-option=45,10.0.0.1
dhcp-option=67,undionly.kpxe
dhcp-option=46,8
dhcp-no-override
dhcp-lease-max=253
#dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
#addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
enable-tftp
tftp-root=/srv/tftp/
tftp-secure
most of the research for this was done by juri grabowski. thanks very much!
see also http://rycee.net/posts/2016-11-13-an-atypical-nixos-install.html