What's missing in my grub2 configuration for PxE
Well after playing with this issue for weeks I finally got the hang of it. I tried what was in the Oracle docs, even tried upgrading to a newer version of the OVS ISO since I found this in the changelog of the next update (3.4.3 and 3.4.4).
Simplified UEFI PXE Boot for Oracle VM Server
As of this release, you do not need to manually build the GRUB 2 boot loader to install Oracle VM Server on UEFI-based systems in a PXE boot environment. The Oracle VM Server ISO image file provides the /EFI/BOOT/grubx64.efi boot loader for UEFI-based systems. See Installing Oracle VM Server for x86 from PXE Boot in the Oracle VM Installation and Upgrade Guide.
Using that version of the grub image didn't work either, no matter where I set the grub.cfg file or how I named it.
I went back to creating my own grub image and this instructions worked like a charm:
-
Create the grub image with this command:
grub2-mkimage -p '(tftp,)/' -O x86_64-efi -d /grub2/lib/grub/x86_64-efi -o /mycore.efi efinet tftp
Create "grub.cfg" with the following (do not change the name of this file) and put it next to your core image and a subdirectory with all the grub2 modules:
set default="1" function load_video { insmod efi_gop insmod efi_uga insmod video_bochs insmod video_cirrus insmod all_video } load_video set gfxpayload=keep insmod gzio insmod part_gpt insmod ext2 set timeout=60 '### END /etc/grub.d/00_header ### echo "Setting root with device lable Oracle VM Server" search --no-floppy --set=root -l 'Oracle VM Server' '### BEGIN /etc/grub.d/10_linux ### menuentry 'Install Oracle VM Server 3.4.4' --class fedora --class gnu-linux --class gnu --class os { echo 'Loading Xen...' multiboot2 /isolinux/xen.gz dom0_mem=max:11582M dom0_max_vcpus=20 noreboot echo 'Loading Linux Kernel...' module2 /isolinux/vmlinuz ip=dhcp vlanid=<vlan> repo=http://<path to ISO> ks=http://<path to kickstart> ksdevice=<device mac address> echo 'Loading initrd...' module2 /isolinux/initrd.img }
Also make sure to point to /mycore.efi in the "filename" directive of your dhcp of course.
At the end my tftp files looked like this:
tftproot grub2 grub.cfg mycore.efi x86_64-efi *.mod isolinux initrd.img TRANS.TBL vmlinuz xen.gz
My crucial mistake was that I was naming the file "grub2.cfg" instead of "grub.cfg". If I had spotted that from the beginning maybe I would have finished this faster.
This answer helped a lot.
Nocturn
Updated on September 18, 2022Comments
-
Nocturn over 1 year
I'm trying to automate the installation of physical servers using PxE. In this case I'm installing Oracle Virtual Servers (OVS for short, RHEL/Centos-like systems with Xen and custom linux kernel). I followed the steps outlined in the official documentation and implemented them using ansible.
To summarize I took in account some important notes:
- I'm using version 3.4.2 so I'm building my own boot loader for UEFI-based PXE clients.
- I'm using Oracle Linux 7.3 since it provides the grub2-tools package that is required to build the GRUB2 boot loader.
With ansible I configured my tftp, dhcp and http servers (for simplicity all of them in the same box) which all seem to be working as expected (tested downloading files and IP assignment and everything works). Here is how I'm building the boot loader
$ grub2-mkimage -p '(tftp,<tftp server IP>)' -O x86_64-efi -d <path to grub2 modules taken from installation iso> -c <path to grub2.cfg file> -o <path to tftp-server dir>/core.efi <embeded modules: net efinet tftp gzio part_gpt efi_gop efi_uga video_bochs video_cirrus all_video ext2 multiboot2 normal>
Here is the current state of my grub2.cfg file:
set timeout=60 # Load modules insmod net insmod efinet insmod tftp insmod gzio insmod part_gpt insmod efi_gop insmod efi_uga insmod video_bochs insmod video_cirrus insmod all_video insmod ext2 insmod multiboot2 insmod normal menuentry 'Install Oracle VM Server 3.4.2' --class fedora --class gnu-linux --class gnu --class os { # dhcp, tftp server in my network set net_default_server=<tftp IP> # This is for testing echo 'Network status: ' net_ls_addr net_ls_routes echo 'Loading Xen...' multiboot2 /isolinux/xen.gz dom0_mem=max:11582M dom0_max_vcpus=20 noreboot echo 'Loading Linux Kernel...' module2 /isolinux/vmlinuz ip=dhcp vlanid=<vlan> repo=http://<Http server IP>/pxelinux/ISOs/OVS3.4.2 ks=http://<http server IP>/pxelinux/kickstart/ovs-3.4.2.ks ksdevice=<mac address of the dhcp configured nic> echo 'Loading initrd...' module2 /isolinux/initrd.img }
The server boots properly, the IP is being set, both the
core.efi
image and thegrub2.cfg
file are being downloaded from the tftp server and I get the "Welcome to Grub!" message but just when it should run what's configured in thegrub2.cfg
file this happens://Start PXE Over IPv4 Station IP Address is X.X.X.X Server IP Address is X.X.X.X NBP filename is /boot/grub2/core.efi NBP filesize is 397824 Bytes Downloading NBP file... Succeed to download NBP file. Downloading NBP file... Succeed to download NBP file. Welcome to GRUB! Unknown command 'menuentry'. Unknown command '#'. Unknown command '#'. Unknown command 'echo'. efinet0 <mac address> <dhcp delivered ip> efinet0:local <net segment>/<netmask> efinet0 efinet0:default 0.0.0.0/0 gw <network gateway> Unknown command 'echo'. Unknown command 'echo'. Unknown command 'echo'. Unknown command '}'.
And finally I'm directed to the grub prompt, where I can type all the commands in the grub2.cfg file correctly and actually boot and install my system with kickstart. So I'm guessing I'm missing something in the grub2 image creation because it's like some modules are not being imported before running the grub2.cfg file?? Only certain commands are being run, the rest are "Unknown".