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
:and the other, which boots clonezilla
tftp/pxelinux.cfg/clonezilla
:and you may add several others, like the one for a diskless thin client (this is actual config I once used):
Then you create symlinks that point to these templates:
In this example, the machines with MAC addresses
10:32:54:76:98:ba
anddc:fe:10:32:54:76
will boot aclonezilla
config file (01
at the beginning of file names here means "Ethernet"), the machine with UUID00801536-e3ee-1610-9957-d68a52030736
will boot athinclient
config, and other machines will bootharddisk
, 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 toharddisk
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 PXELinuxinclude
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.I simply added a iPXE entry (with a iPXE 'script' in an initrd file) to
/etc/grub.d/
(starting with '99' so that it's at the end of the list), then runupdate-grub
, then ranthis simply counts the
menuentries
in the grub.cfg file, and tells grub-reboot to boot into the last option on next reboot.