Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
soc:2009:pravin:journal:pxekniferomomatic [2009/06/04 06:25]
less1
soc:2009:pravin:journal:pxekniferomomatic [2009/06/04 14:47] (current)
less1
Line 1: Line 1:
-====== Pxeknife integretion with pxeknife ​======+====== Pxeknife integretion with rom-o-matic ​======
  
  
Line 5: Line 5:
  
 provide pxe images/​rom/​nic with gpxe script embedded. ​ This script will connect to pxeknife server to get boot loader. provide pxe images/​rom/​nic with gpxe script embedded. ​ This script will connect to pxeknife server to get boot loader.
 +
  
 ===== Implementation ===== ===== Implementation =====
 +Actual working implementation is described [[PxeKnifeRomOMaticHTTP|here]]
  
 In file rom-o-matic/​build.php the image is compiled by following command In file rom-o-matic/​build.php the image is compiled by following command
Line 15: Line 17:
 I have modified it to compile with embedded image by modifying above code with I have modified it to compile with embedded image by modifying above code with
 <​code>​ <​code>​
-make -C '​$dir'​ EMBEDDED_IMAGE=./​pxeDHCP.gpxe '​$target'​+make -C '​$dir'​ EMBEDDED_IMAGE=./​pxeDHCP.gpxe,​./​pxeSTATIC.gpxe '​$target'​
 </​code>​ </​code>​
  
-===== Problems =====+the script //​./​pxeDHCP.gpxe//​ contains following code 
 +<​code>​ 
 +#!gpxe 
 +echo "Hi, We will be using PXEKnife from URL http://​www.alien.doesntexist.org/​pxeknife"​ 
 +echo "It is assumed that you have dhcp networking"​ 
 +imgload pxeSTATIC.gpxe 
 +imgstat 
 +ifopen net0 
 +echo "Hit Control+C to cancel DHCP"​ 
 +echo "You may want to do this if you want to use static-IP"​ 
 +echo "​Otherwise,​ it will try DHCP, and then anyway go to static-IP"​ 
 +sleep 4 
 +dhcp net0 
 +set 209:string pxelinux.cfg/​default 
 +set 210:string http://​www.alien.doesntexist.org/​pxeknife/​ 
 +echo "Here we go" 
 +chain http://​www.alien.doesntexist.org/​pxeknife/​pxelinux.0 
 +echo "​PxeKnife booting cancelled, using local disk instead.."​ 
 +</​code>​ 
 +and //​./​pxeSTATIC.gpxe//​ contains following script. 
 +<​code>​ 
 +#!gpxe 
 +echo "As you dont have DHCP, you need to give details about network configuration"​ 
 +echo "Soon, you will be presented with interface to provide details about network configuration"​ 
 +echo "​Please provide, IP address, Netmask, Gateway and Router"​ 
 +ifopen net0 
 +set net0/ip 10.0.2.15 
 +set net0/​netmask 255.255.255.0 
 +set net0/​gateway 10.0.2.2 
 +set net0/dns 10.0.2.3 
 +sleep 3 
 +config 
 +set 209:string pxelinux.cfg/​default 
 +set 210:string http://​www.alien.doesntexist.org/​pxeknife/​ 
 +echo "Here we go" 
 +chain http://​www.alien.doesntexist.org/​pxeknife/​pxelinux.0 
 +echo "​PxeKnife booting cancelled, using local disk instead.."​ 
 +</​code>​ 
 + 
 + 
 +The code is hosted at url [[http://​www.alien.doesntexist.org/​pxeknife/​PHP/​gpxe_generation/​]] 
 + 
 + 
 + 
 +===== Problems ​(solved) ​===== 
 + 
 +When I boot using qemu with following command 
 +<​code>​ 
 +qemu -fda gpxe-git-e1000.dsk 
 +</​code>​ 
 +I get following error 
 + 
 +<​code>​ 
 +no such interface: net0 
 +</​code>​ 
 +and booting fails :-(. I also tried with gpxe-git-3c509-eisa.dsk but same result.\\ 
 + 
 +But when I compile the the gpxe with same script and no target, it works fine 
 + 
 + 
 +<​code>​ 
 +make EMBEDDED_IMAGE=./​pxeDHCP.gpxe 
 +qemu -fda bin/​gpxe.dsk 
 +</​code>​ 
 + 
 +==== Solution ==== 
 +Problem was that, qemu does not support all network drivers, and you need to tell qemu which device driver to emulate. 
 +Following qemu command is working for rtl8139 
 +<​code>​ 
 +qemu -fda gpxe-git-rtl8139.dsk -net nic,​model=rtl8139 -net user 
 +</​code>​ 
 + 
 +===== For static IP ===== 
 +To support static IP, the plan is to have two scripts, one with DHCP and one with Static. 
 +When DHCP fails, static will pick up and continue execution. 
 + 
 +==== Problem (solved) ==== 
 +Second script is not getting executed. 
 +I had to load the second script from first script using imgload 
 +<​code>​ 
 +imgload pxeSTATIC.gpxe 
 +</​code>​ 
 +Other than that, 
 +I had to comment out the break statement in //​core/​main.c//​ inside function //main()//  
 +there is a loop which iterate over each image. but there was a break, which had to be removed. 
 +<​code>​ 
 +        if ( have_images() ) { 
 +            for_each_image ( image ) { 
 +                image_exec ( image ); 
 +                /* break; ​ */ /* commented so that second script will be executed -- pravin */ 
 +            } 
 +        } else { 
 + 
 +</​code>​ 
 + 
 +Other change is done in //​image/​script.c//​ file inside function //​script_exec()//​ where at end, it re-registers the script. 
 +The second executable does not get executed when this line is there, so, I commented it out. 
 +I am not sure what exactly is the problem, but my guess is that, \\ 
 +re_register puts the script on top of the list, but older mapping where second script ​ was loaded in memory gets messed up somehow. 
 + 
 +<​code>​ 
 +    rc = 0; 
 + ​done:​ 
 +    /* Re-register image and return */ 
 +    register_image ( image );    /* commented so that next one will be executed -- pravin */ 
 +    return rc; 
 +
 + 
 +</​code>​
  

QR Code
QR Code soc:2009:pravin:journal:pxekniferomomatic (generated for current page)