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 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # How to boot a diskless VM with iPXE over NFS using only IPv6
  2. I have encountered 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. Debian/Ubuntu ipxe-qemu patching
  10. ```
  11. apt-get update
  12. apt-get source ipxe-qemu
  13. apt-get build-dep ipxe-qemu
  14. cd ipxe-1.0.0+git-20180124.fbe8c52d # or whatever your version is
  15. dch -n "add support for serial console / IPv6"
  16. # apply the modifications above
  17. debuild -b -uc -us
  18. cd ..
  19. dpkg -i ipxe-qemu_*.deb
  20. ```
  21. # Kernel options
  22. 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)
  23. * `ip=:::::eth0:off` (disable IPv4 on the PXE interface)
  24. * `ip6=eth0` (enable IPv6 on the PXE interface)
  25. * `nfsroot=<hostname>:<path>` (mounting IPv6 NFS shares using a literal IPv6 **WILL FAIL**, you **MUST** use a hostname)
  26. Those options will tell the initrd script which interface and protocol is desired.
  27. # Hooks in initramfs
  28. 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).
  29. 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.
  30. In `/etc/initramfs-tools/hooks/` create an executable script with the name of your choice. Here's the content:
  31. ````
  32. #!/bin/bash
  33. . /usr/share/initramfs-tools/hook-functions
  34. # copy all the name libraries (for DNS to work)
  35. cp -fpL /lib/x86_64-linux-gnu/libns* ${DESTDIR}/lib/x86_64-linux-gnu/
  36. # copy helper files needed by mount.nfs
  37. for file in /etc/protocols /etc/netconfig
  38. do cp $file ${DESTDIR}${file}; done
  39. # uncomment to embed in your setup, can be useful for debugging
  40. # copy_exec /sbin/dhclient /sbin
  41. # copy_exec /bin/ping /bin
  42. # copy_exec /usr/bin/strace /bin
  43. # replace the busybox nfsmount with mount.nfs (this way we don't need to modify the included nfs script which calls nfsmount)
  44. cp /sbin/mount.nfs ${DESTDIR}/bin/nfsmount
  45. # this little hack will find all libraries needed by mount.nfs, locate them and copy them.
  46. for lib in `ldd /sbin/mount.nfs | awk '{print $1}'`
  47. do
  48. found=0
  49. for path in /lib /lib/x86_64-linux-gnu /usr/lib /usr/lib/x86_64-linux-gnu
  50. do
  51. if [ -r "${path}/${lib}" ]
  52. then
  53. cp -L ${path}/${lib} ${DESTDIR}/${path}/${lib}
  54. found=1
  55. fi
  56. done
  57. if [ ! $found ]
  58. then
  59. echo "ERROR: Cannot find ${lib}"
  60. exit 1;
  61. fi
  62. done
  63. ````
  64. After that you'll need to `update-initramfs -u`
  65. # Boot
  66. **Boot and it should just work! Happy IPv6!**