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.

README.md 2.8KB

5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # How to boot a diskless VM with iPXE over NFS using only IPv6
  2. I have encountered 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` (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. NOTE: Be aware that this will increase the size of initrd. In my case it went to ~16MB which is still way less than on a physical host (~60MB).
  17. 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.nfs.
  18. In `/etc/initramfs-tools/hooks/` create an executable script with the name of your choice. Here's the content:
  19. ````
  20. #!/bin/bash
  21. . /usr/share/initramfs-tools/hook-functions
  22. # copy all the name libraries (for DNS to work)
  23. cp -fpL /lib/x86_64-linux-gnu/libns* ${DESTDIR}/lib/x86_64-linux-gnu/
  24. # copy helper files needed by mount.nfs
  25. for file in /etc/protocols /etc/netconfig
  26. do cp $file ${DESTDIR}${file}; done
  27. # uncomment to embed in your setup, can be useful for debugging
  28. # copy_exec /sbin/dhclient /sbin
  29. # copy_exec /bin/ping /bin
  30. # copy_exec /usr/bin/strace /bin
  31. # replace the busybox nfsmount with mount.nfs (this way we don't need to modify the included nfs script which calls nfsmount)
  32. cp /sbin/mount.nfs ${DESTDIR}/bin/nfsmount
  33. # this little hack will find all libraries needed by mount.nfs, locate them and copy them.
  34. for lib in `ldd /sbin/mount.nfs | awk '{print $1}'`
  35. do
  36. found=0
  37. for path in /lib /lib/x86_64-linux-gnu /usr/lib /usr/lib/x86_64-linux-gnu
  38. do
  39. if [ -r "${path}/${lib}" ]
  40. then
  41. cp -L ${path}/${lib} ${DESTDIR}/${path}/${lib}
  42. found=1
  43. fi
  44. done
  45. if [ ! $found ]
  46. then
  47. echo "ERROR: Cannot find ${lib}"
  48. exit 1;
  49. fi
  50. done
  51. ````
  52. After that you'll need to `update-initramfs -u`
  53. # Boot
  54. **Boot and it should just work! Happy IPv6!**