Ask.Cyberinfrastructure

Running Different GRUB2 Configuration for Multiple Diskless Clients?

My setup has one head node which hosts a bootable image, which many compute nodes PXE boot from using grub. The issue is because of the varying hardware of the various nodes, I need different grub configurations (to load different images) to different clients.

First, I tried this. My network has all nodes with lets say configuration “A” under the IP range 10.0.1.1-10.0.15.255, and configuration “B” in the range 10.0.16.1-10.0.31-255. I tried creating the files grub.cfg-0A000, and grub.cfg-0A001, respectively, but it seemed to load the default grub.cfg anyway.

Then, I tried using the variable $net_default_ip and the regexp command to determine which ip range the node is located in, and set a default menu item based on that. The issue is, there is next to no documentation about this command that I could find. I tried using a standard POSIX regex syntax: if regexp /10\.0\.1\.1/gx;, but this conditional seems to return true every time, and the default menu item is simply my last if statement. Creating individual if statements for each node works: if [ "$net_default_ip" = "10.0.1.1" ];, however, I would prefer not to go this route because of the amount of nodes that this would have to be done for, not to mention new nodes that would be added in the future.

Any help would be greatly appreciated, I’m at a loss at this point.

Have you looked at iPXE (http://ipxe.org) for handling this? It’s pretty straightforward to use PXE to bootstrap iPXE, and once done you can have iPXE pull its configuration from http(s). If you have that point to a simple CGI then you can have that CGI return whatever config you want based on the parameters it gets in the request, which can include things like the system MAC address, see http://ipxe.org/scripting