Instructions how to make a diskless VM with iPXE and NFS using IPv6 only.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 5 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # How to boot a diskless VM with iPXE over NFS using only IPv6
  2. I have encoutered so many issues and countless hours trying to figure this out, but I finally succeeded. Reading source code, strace'ing binaries trying to figure out what was wrong with them.
  3. # iPXE
  4. iPXE will do IPv4 DHCP first and then IPv6 SLAAC/DHCP. This is not a problem, it's just annoying. IPv4 DHCP has a default timeout in iPXE of 10 seconds.
  5. What you need to do in iPXE:
  6. * enable serial console -> `src/config/console.h` -> `#define CONSOLE_SERIAL`
  7. * enable IPv6 -> `src/config/general.h` -> `#define NET_PROTO_IPV6`
  8. * mangle IPv4 DHCP timeout -> `src/config/dhcp.h` -> `#define DHCP_DISC_END_TIMEOUT_SEC 1`
  9. # Kernel options
  10. Make sure you pass the right kernel options for initramfs/initrd to know exactly what you want to do. (replace eth0 with the name of your PXE interface)
  11. * `ip=:::::eth0:off` (disable IPv4 on the PXE interface)
  12. * `ip6=:::::eth0:on` (enable IPv6 on the PXE interface)
  13. * `nfsroot=<hostname>:<path>` (mounting IPv6 NFS shares using a literal IPv6 **WILL FAIL**, you **MUST** use a hostname)
  14. Those options will tell the initrd script which interface and protocol is desired.
  15. # Hooks in initramfs
  16. A few files must be copied to the initramfs in order to make this work. First we need DNS to work and secondly we need to replace the busybox nfsmount with mount.nfs4 (don't worry, it can also do NFS3).
  17. In /etc/initramfs-tools/hooks create an executable script with the name of your choice. Here's the content:
  18. ````
  19. #!/bin/bash
  20. . /usr/share/initramfs-tools/hook-functions
  21. # copy all the name libraries (for DNS to work)
  22. cp -fpL /lib/x86_64-linux-gnu/libns* ${DESTDIR}/lib/x86_64-linux-gnu/
  23. # copy helper files needed by mount.nfs4
  24. for file in /etc/protocols /etc/netconfig
  25. do cp $file ${DESTDIR}${file}; done
  26. # uncomment to embed in your setup, can be useful for debugging
  27. # copy_exec /sbin/dhclient /sbin
  28. # copy_exec /bin/ping /bin
  29. # copy_exec /usr/bin/strace /bin
  30. # replace the busybox nfsmount with mount.nfs4 (this way we don't need to modify the included nfs script which calls nfsmount)
  31. copy_exec /sbin/mount.nfs4 /bin/nfsmount
  32. ````
  33. After that you'll need to `update-initramfs -u`
  34. # Boot
  35. **Boot and it should just work! Happy IPv6!**