Advertisement
Guest User

turnkey casper http pxe

a guest
May 26th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. To me it seems like the netboot code is broken, passing parameter ip=dhcp or ip=[CLIENT_IP]:[SERVER_IP]:[GATEWAY_IP]:[NETMASK]:[HOSTNAME]:[DEVICE]:[AUTOCONF] as exampled by ip=10.0.0.1::10.0.0.254:255.255.255.0::eth0 or ip=:::::eth0:dhcp does not allow the configure_network() function to establish networking in the exisitng code. After realising it was the network config that was throwing me off I've put together a patch that replaces configure_network() with a simple ipconfig statement and adds support for netboot=http fetch=http://..../root.squashfs. There is a limitation in the initramfs where there is not dns resolver so url and nfsroot has to be IP address only. iPXE can work around it by letting iPXE resolve dns names and pass IP to kernel.
  2. As far as I can tell it works with both nfs and http, dhcp and static ip.
  3.  
  4. casper-http-simple.patch
  5.  
  6. --- initrd/scripts/casper 2016-05-26 11:11:48.505135324 +0200
  7. +++ initrd-http/scripts/casper 2016-05-26 11:20:21.969120753 +0200
  8. @@ -32,6 +32,10 @@
  9. parse_cmdline() {
  10. for x in $(cat /proc/cmdline); do
  11. case $x in
  12. + netboot=*)
  13. + export NETBOOT="${x#netboot=}";;
  14. + fetch=*)
  15. + export URL="${x#fetch=}";;
  16. showmounts|show-cow)
  17. export SHOWMOUNTS='Yes' ;;
  18. persistent)
  19. @@ -191,26 +195,48 @@
  20. /sbin/udevadm trigger
  21. /sbin/udevadm settle
  22.  
  23. - ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
  24. + #this seems broken.
  25. + #ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
  26. + #replace with very basic netconfig based on ip= parameter
  27. + case ${STATICIP} in
  28. + dhcp)
  29. + ipconfig :::::eth0:dhcp
  30. + ;;
  31. + *)
  32. + ipconfig ${STATICIP}
  33. + ;;
  34. + esac
  35.  
  36. if [ "${NFSROOT}" = "auto" ]; then
  37. NFSROOT=${ROOTSERVER}:${ROOTPATH}
  38. fi
  39.  
  40. - [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}"
  41. -
  42. - if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then
  43. - rc=0
  44. - elif do_nfsmount ; then
  45. - NETBOOT="nfs"
  46. - export NETBOOT
  47. - rc=0
  48. - fi
  49. + case ${NETBOOT} in
  50. + nfs)
  51. + [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}"
  52. + if do_nfsmount ; then rc=0; fi ;;
  53. + cifs)
  54. + [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}"
  55. + if do_cifsmount ; then rc=0; fi ;;
  56. + http|httpfs)
  57. + [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${URL}"
  58. + if do_httpmount ; then rc=0; fi ;;
  59. + esac
  60.  
  61. [ "$quiet" != "y" ] && log_end_msg
  62. return ${rc}
  63. }
  64.  
  65. +do_httpmount() {
  66. + rc=1
  67. + livefs_root=/tmp/root
  68. + mkdir -p ${livefs_root}
  69. + mount -t tmpfs -o size=`wget ${URL} --spider --server-response -O - 2>&1 | sed -ne '/Content-Length/{s/.*: //;p}'` tmpfs ${livefs_root}
  70. + mkdir -p ${livefs_root}/casper
  71. + if wget ${URL} -O ${livefs_root}/casper/root.squashfs; then rc=0; fi
  72. + return ${rc}
  73. +}
  74. +
  75. do_nfsmount() {
  76. rc=1
  77. modprobe "${MP_QUIET}" nfs
  78. patch-initrd-from-iso.sh (asume .iso and .patch is in pwd to start with)
  79.  
  80. export TKL=turnkey-core-14.1-jessie-amd64
  81. rm -rf ~/${TKL}
  82. mount -o loop ${TKL}.iso /mnt
  83. mkdir ~/${TKL}
  84. cp casper-http-simple.patch ~/${TKL}
  85. cd ~/${TKL}
  86. cp -r /mnt/casper .
  87. umount /mnt
  88. mkdir -p casper/initrd
  89. cd casper/initrd
  90. gunzip -c ../initrd.gz | cpio -i
  91. patch -p1 < ~/${TKL}/casper-http-simple.patch
  92. find . | cpio -H newc -o | gzip -9 > ../initrd.gz
  93. cd ..
  94. rm -r initrd
  95. tkl.ipxe
  96.  
  97. #!ipxe
  98. set server x.x.x.x
  99. set path boot/tkl
  100. #nslookup serverip ${server}
  101. #set server ${serverip}
  102. dhcp
  103. kernel http://${server}/${path}/vmlinuz
  104. initrd http://${server}/${path}/initrd.gz
  105. imgargs vmlinuz boot=casper di-live single noinithooks ip=dhcp netboot=http fetch=http://${server}/${path}/10root.squashfs
  106. boot || shell
  107.  
  108. menu entry for pxelinux.0 to chainload iPXE
  109.  
  110. label iPXE-TKL
  111. menu label iPXE ^Turnkey Linux
  112. kernel ipxe.krn dhcp && chain http://x.x.x.x/boot/tkl.ipxe || shell
  113.  
  114. menuentry "iPXE Turnkey Linux" for grub
  115.  
  116. {
  117. linux16 /ipxe.lkrn
  118. initrd16 /tkl.ipxe
  119. ​}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement