Run a custom Ipxe command depending on the host
-
Hello
I have been playing around a little bit on FOG and I want to use it to make diskless machines and make them boot from iscsi drives (I know that that is not the intended use of the system but I think that it my be worth a try).
While I was able to install ubuntu on an Iscsi drive and make the remote computer boot from a custom menu option (sanboot) I want to be able to boot automatically from the Iscsi and also depending on the host give him the correct parameters for the sanboot command
Will that be possible?
BTW sorry for my bad english, it is not my native language. -
@UMB8998 While it is possible to create custom iPXE entries within FOG I am not sure it’s the right tool for what you want to achieve. Please tell us more about the parameters that need to be different for your hosts for us to get an idea what you are aiming for.
-
Hello Sebastián,
Basically I just need a different ipxe command to boot the machine to a different iscsi drive, for example host1 will be booting using the ipxe command “sanboot iscsi:192.168.10.10::::iqn.2010-05.org.freenas.ctl:host1” while host2 is booting to another iscsi drive using “sanboot iscsi:192.168.10.15::::iqn.2007-08.org.freenas.ctl:ubuntu” -
@umb8998 So what are you trying to do here? Is this for imaging or for netbooting because the approach is a bit different. I would have to double check, but I think sanboot is only for BIOS based computers not uefi.
If you are building a netboot environment and not imaging with FOG then we have some options.
What is the scale of what you are doing here. Is this for 10 systems or 100 systems?
-
@george1421 this is for netbooting, I have a cluster of RasperryPi (ARM) and Other SoC (x86) which i want to be able to boot each from a different iscsi.
About the sanboot I was able to boot ubuntu on legacy and on uefi mode (i had to reinstall the grub) on diferent computers.
The scale is not so big, I have now 6 pi and 1 x86 device for testing and if it works I was looking on getting around another 15 devices -
@umb8998 Ok great. Sorry Initially I got this confused with another thread regarding apple pxe booting.
OK for 20 systems or less I would go a slightly different approach and not use FOG at all. There is more overhead than you really need. BUT with that said you can reverse engineer how FOG does this to develop your own custom approach. I would surely “borrow” the iPXE boot loaders that FOG uses. Because that is the engine that will get your netbooting system working.
You will also need a tftp server. It doesn’t need to be the fog server. It can be another linux server, a raspberry pi running Raspbian, or a windows computer running tftp64d. You need something to pass out the netboot files.
Now here is where things will diverge from FOG. When your target computer pxe boots, it will query dhcp server for dhcp options 66 and 67. These need to point to your tftp server. The pxe computer is going to load undionly.kpxe or ipxe.efi. When that boot loader starts FOG puts an embedded script to read in dhcp option 66 and chains to a text file called default.ipxe (ipxe specific batch file) on the tftp server (pointed to by dhcp option 66). In FOG Land that default.ipxe then chains to boot.php on the fog server. What I’m suggesting is that you take that default.ipxe and make it your own. (you can do this with your fog server today). Create a custom script that runs in default.ipxe to identify the pxe booting computer’s mac address then chain to the proper sanboot command based on the mac address.
So how do you get started? By reverse engineering what the FOG Developers have done, of course. Point your browser to the fog server at this url.
http://<fog_server_ip>/fog/service/ipxe/boot.php?mac=00:00:00:00:00:00
That will display the FOG iPXE menu. Look how that menu is crafted. That will give you a good idea of how it flows and the commands used. Couple that with researching the commands on the iPXE project page. You should be able to quite easily create your own default.ipxe file that reads the pxe booting computer’s mac address do a simple if check and then call the appropriate sanboot command to boot your system.You don’t need FOG, its programming logic, or database to do this. It can all be done in that default.ipxe script. Now I wouldn’t take this approach if you had 100s of computers, but for less than 20 you can create a unique test based on the mac address pretty easily.
-
@umb8998 said in Run a custom Ipxe command depending on the host:
The scale is not so big, I have now 6 pi and 1 x86 device for testing and if it works I was looking on getting around another 15 devices
In this case FOG is overkill and changing it the way you want it you’d spend more time than coming up with your own solution. Don’t get me wrong, you are free to use whatever you want and I suggest you use the iPXE binaries we provide for FOG but for the dynamic part of sending different iSCSI addresses to the hosts I don’t think FOG is a good tool for you. Just install Apache (or use it if you have FOG installed already) and write a simple PHP script to send different iSCSI addresses depending on the MAC address of the host booting. That is super easy to code.
-
Along the same lines as Sebastian mentioned here is a rough outline of what needs to be done. http://brandon.penglase.net/index.php?title=PXE_Booting_and_Utilities_Menu
But as I said for less than 20 hosts I would just go hard coding into the default.ipxe file and not worry about database integration. For 30 hosts I might consider it.
-
@george1421 @Sebastian-Roth Thank you very much for the recommendation I would try to integrate it into the database just for the trill of it, I may even try to edit the php to integrate it into the original system.
Thanks