0

I do want to do symlinks like pxelinux can, just with grub2. But I cant figure out how. The goal is to have different config-files which I can dynamicly pass to an IP.

Grub2 does work so far but I cant give an IP another config file, it always takes the grub.cfg. I tried also grub.cfg-IP -> another config file -> is a symlink to the config file I actually want to use.

Maybe someone did figure this out already. Grub2 Manual didnt help much.

2

PXELINUX is not "doing symlinks": it's just downloading a configuration file whose name includes the client's IP or MAC address or part of it. The fact that the matching file happens to be a symlink is entirely between you and your TFTP server that provides the file to PXELINUX.

Note that unlike PXELINUX, GRUB only looks for a single configuration file, which is grub.cfg by default. So that's what you need to supply it. If you want GRUB to use a configuration file whose name is somehow dependent on client's IP address, you'll need to tell that to GRUB.

That configuration file can then tell GRUB to load another configuration file... and you can use GRUB environment variables when specifying its name.

So, if you want GRUB to use a configuration file named grub.cfg-<IP address>, then you should first create a very minimal grub.cfg file in the location expected by GRUB, and have it say something like this (only):

configfile grub.cfg-${net_default_ip}

This should tell GRUB to download a new configuration file with the client IP address suffixed to the filename.

You might even specify the new configuration file with an absolute path, with something like

configfile (tftp,${net_default_server})/some/path/grub.cfg-${net_default_ip}

If you don't like having a separate grub.cfg file with just the one line defining a new configuration file, you could embed this one-line configuration into the GRUB PXE boot image, by using grub-mkimage -c <grub.cfg containing the configfile command> -O i386-pc-pxe <other parameters...> (or whichever architecture you're using).


You've probably already discovered that when you're having trouble getting PXE boot working, it's useful to dump the network traffic between the PXE client and the DHCP/TFTP server(s) with something like tcpdump or wireshark to verify the client is getting the correct information and requesting the correct files in turn... right?

  • 1
    This did not work for me. I needed to do configfile = grub.cfg-$net_default_ip and then configfile $configfile . I dont know why but I am glad it does work now. Thank you. – Lizzi Jun 1 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.