Tell Linux/GRUB to start iPXE on next boot?

I've just discovered the wonder that is iPXE.

Im running various versions of Debian on many different computers, and would like to remotely tell them to reboot into iPXE, and have iPXE automatically boot into a clonezilla auto-deploy .iso I have.

Is there a way to tell Linux to automatically boot into iPXE on next boot once, and have iPXE then automatically boot into an .iso from a server?


I use similar setup, but in reverse. In the end, I can control from the server how my target machines boot.

However, I don't rely on the grub on the target machine and I don't use iPXE.

Instead, I installed a PXE boot server. It is extremly hard nowadays to find a computer with non-working PXE boot. So I configured all computers I need to control this way to boot from the network via PXE.

By the way, this is equally possible with old-style BIOS and modern UEFI machines, and it is DHCP server who distingushes between these cases and suggests the appropriate bootloader to the machine.

In any case, machines load some variant of PXELinux. It has a neat property, in that how it searches for a config file. It first requests a config file named after machine SMBIOS UUID, if it's not found, if requests a file named after the MAC address of the interface which was booted, IP address, and if nothing helps, it requests a file default.

So you can create some "base configs", one which boots machines from local hard disk tftp/pxelinux.cfg/harddisk:

default harddisk

label harddisk
    localboot 0

and the other, which boots clonezilla tftp/pxelinux.cfg/clonezilla:

default clonezilla

label clonezilla
#    clonezilla boot instructions here

and you may add several others, like the one for a diskless thin client (this is actual config I once used):

default stretch

label stretch
    linux thinclient/vmlinuz-4.9.0-7-amd64
    initrd thinclient/initrd.img-4.9.0-7-amd64
    append ISCSI_INITIATOR=iqn.1993-08.org.debian:01:a4c444f2b735 ISCSI_TARGET_NAME=iqn.2018-10.ru.rterm.office.test-storage:thinclient.lvm ISCSI_TARGET_IP=192.168.168.113 ISCSI_TARGET_PORT=3260 root=UUID=344ca052-8ea2-437f-9550-a5503d0e7b21 ip=dhcp quiet

Then you create symlinks that point to these templates:

cd tftp/pxelinux.cfg
ln -s clonezilla 01-10-32-54-76-98-ba
ln -s clonezilla 01-dc-fe-10-32-54-76
ln -s harddisk 01-98-ba-dc-fe-10-32
ln -s harddisk 01-54-76-98-ba-dc-fe
ln -s harddisk default
ln -s thinclient 00801536-e3ee-1610-9957-d68a52030736  

In this example, the machines with MAC addresses 10:32:54:76:98:ba and dc:fe:10:32:54:76 will boot a clonezilla config file (01 at the beginning of file names here means "Ethernet"), the machine with UUID 00801536-e3ee-1610-9957-d68a52030736 will boot a thinclient config, and other machines will boot harddisk, but the two with specified MACs will do this quieter (less "file not found" logs on the server and sligtly faster boot because the download attempt will succeed earlier).

Now, if you need some machine to boot, say, clonezilla, you create or change its symlink on the tftp server to clonezilla. After it was booted, you may revert the change (e.g. change to harddisk or whatever you want). You may create configs for Linux network installation — I don't even remember when I last time boot installer from USB, because I always install it this way for several years. You may use the PXELinux include directive and create a neat generic menu with all these options to select by hand and use it for a default instead. Technically, even Windows installation is (was) possible this way. The scheme is very flexible, and the only thing it depends on the client machine is that it boots from the network first.