PXE multi-boot server using grub2 on Mikrotik RouterOS ( bios and efi support )

This article describes how to setup a network multi-boot environment which works for EFI and BIOS netboot clients with example application for:

  1. Configure GRUB to boot from network
  2. Configure GRUB as standalone (all-in-one) EFI image ( alternative approach )
  3. Mikrotik configuration

Configure GRUB to boot from network

In order to use grub you need to use at least grub in version 2.00 beta3. Using virtual machine from VMWare I was not able to boot R-Drive image. What’s more, using http://tftpd32.jounin.net/ tftp server even grub was not booting properly ( can not load some modules ).  Grub bugtracker

 

BIOS image

Create grub efi image ( booti386 ).

grub-mkimage -d /usr/lib/grub/i386-pc/ -O i386-pc-pxe -o ./booti386 -p '(tftp)/grub' pxe tftp

Place booti386 in root of tftp server and set it as ‘boot file name’ in dhcp server

grub.cfg should be place in tftp:grub/directory. Copy also efi module to tftp:grub/i386-pc  from /usr/lib/grub/i386-pc

EFI image

Create grub efi image ( bootx64.efi ).

grub-mkimage -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi -o ./bootx64.efi -p '(tftp)/grub' efinet tftp

If You are using i386 arch then install missing files:

apt-get install grub-efi-amd64-bin

Place bootx64.efi in root of tftp server and set it as ‘boot file name’ in dhcp server

grub.cfg should be place in tftp:grub/directory. Copy also efi module to tftp:grub/x86_64-efi  from /usr/lib/grub/x86_64-efi


Configure GRUB as standalone (all-in-one) EFI image ( alternative approach )

Standalone grub file contains build in configuration and module files.

Efi image:

grub-mkstandalone -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi --fonts="unicode" -o ./bootx64.efi "boot/grub/grub.cfg=./grub_buildin.cfg

grub_efi_standalone.cfg used to make standalone efi image:

In case of problem with ‘net_bootp’ module please ensure, that mikrotik dhcp for ‘Bootp support’ is set do ‘dynamic’


Mikrotik configuration

DHCP server

To use ‘net_bootp’ module from grub standalone build you need to set “Bootp support” in mikrotik dhcp configuration to ‘dynamic’.

TFTP server

Point tftp server where to search for files requested by client.

BIOS and UEFI Co-Existence

At the time of writing this text, it’s not possible to set different boot file depend of client platform: Mikrotik forum. Alternative you can use linux wiki.fogproject.org as dhcp server