Getting FOS on a bootable ISO image
-
Every now and then, we get a system in our lab that just will not do a PXE boot. Most of these are pre-production hardware with some BIOS or network hardware issue, and sometimes it’s a production system with some unspecified issue, but the result is the same: PXE, though supposedly supported by the hardware, just does not work.
To inventory and image these systems, I need a way for them to boot FOS. And that means feeding it a bootable image via the USB port.
There is a nice tutorial that will help me create a bootable USB device, but my problem is that the hardware is sitting in a server room 8 miles away, so inserting a USB drive is not exactly convenient. What I do have, though, is access to the Raritan KVM-over-IP that will give me a console session to the system, and it also lets me remote-mount an ISO image that the BIOS on the system will recognize via the USB port, and boot in either legacy or UEFI mode.
For that to work, however, I need to have a bootable ISO image.
I’ve tried a number of alternatives, many involving trickery trying to get a bootable USB stick to work as a remote image for the device, but I’ve not been successful. I’ve got to have an actual, bootable ISO. And I am out of my depth. I do not know how to create a bootable ISO image of FOS. I’ve spent some time with mkisofs and the above tutorial trying to turn the image and/or the source files into an ISO that will boot, but I have not had success. So I am stuck and need help.
Has anyone done this? If so, can you please give me some hints?
-
@mechalas First question that arises in this context is: UEFI or legacy BIOS boot?
-
@sebastian-roth UEFI boot
-
This post is deleted! -
@mechalas Just figured that iPXE can build an ISO for UEFI just as well as for legacy BIOS systems.
So following our wiki entry on iPXE compilation and using this build command should be all you need to do:
UEFI:
make bin-x86_64-efi/ipxe.iso EMBED=ipxescript
legacy BIOS:make bin/ipxe.iso EMBED=ipxescript
(though not in the same source directory as it needs different headers - carefully read the wiki!) -
@sebastian-roth I will give this a shot. Thank you!
-
So these instructions build iPXE, and I presume the idea is to chain load the FOG image from the server?
I am not sure if that will help me. What I really need is to be able to boot FOS directly from an iso. I am leery of involving PXE in the process at all.
-
@mechalas said in Getting FOS on a bootable ISO image:
@sebastian-roth UEFI boot
UEFI is pretty simple to boot. I have a few tutorial depending on where you want to jump into the process.
I think the simpliest one for uefi is this: https://forums.fogproject.org/topic/6350/usb-boot-uefi-client-into-fog-menu-easy-way
If you want to boot right into fos linux with some of the limitations of the process: https://forums.fogproject.org/topic/7727/building-usb-booting-fos-image
-
@mechalas said in Getting FOS on a bootable ISO image:
So these instructions build iPXE, and I presume the idea is to chain load the FOG image from the server?
I am not sure if that will help me. What I really need is to be able to boot FOS directly from an iso. I am leery of involving PXE in the process at all.Yes and no. While loading iPXE from the ISO is skipping some major part of PXE booting it would still need the DHCP server to hand out PXE information (at least option 66 - next server) for iPXE to be able to pull the next file via TFTP.
Well then it’s going to be the more complicated way of building an ISO with GRUB and FOS kernel&init. Will provide further information on that soon.
-
@sebastian-roth I did give this a shot on one of our problem systems. It had a 25% success rate, meaning it took four tries before it worked. The first three tries, it hung at “iPXE Initializing devices” and had to be power-cycled (which, thankfully, I can do remotely). The fourth time it worked, which is the first time this system has ever successfully PXE booted.
-
@mechalas After playing with this stuff for a bit I came up with two different ways to create an UEFI bootable FOS ISO.
Using grub-mkrescue:
Hint: For this to work you need an UEFI based 64 bit Linux system that you can use to create the ISO. If you try this on a BIOS machine or 32 bit system it will still build the ISO for you but it might not boot on 64 bit UEFI systems.sudo -i apt install grub-efi-amd64-bin mtools xorriso mkisofs mkdir -p iso/boot/grub cp /var/www/html/fog/service/ipxe/bzImage iso/boot/ cp /var/www/html/fog/service/ipxe/init.xz iso/boot/ vi iso/boot/grub/grub.cfg grub-mkrescue -o fos-x86_64-efi.iso iso/
Insert whatever
grub.cfg
you want. For example use the one @george1421 posted in his tutorial on USB booting. Be aware that you definitely need to use the kernel parameterboottype=usb
to make it pull the parameters that iPXE would receive and pass on through the dynamic boot instructions generated.Using grub-mkstandalone and xorriso manually:
sudo -i apt install grub-efi-amd64-bin mtools xorriso mkisofs mkdir -p iso/boot/grub/ mkdir -p iso/EFI/BOOT/ cp /var/www/html/fog/service/ipxe/bzImage iso/boot/ cp /var/www/html/fog/service/ipxe/init.xz iso/boot/ vi iso/boot/grub/grub.cfg grub-mkstandalone -o iso/EFI/BOOT/BOOTX64.EFI -O x86_64-efi "boot/grub/grub.cfg=iso/boot/grub/grub.cfg" dd if=/dev/zero of=iso/EFI/BOOT/efiboot.img bs=1M count=10 mkfs.msdos -F 12 -n 'EFIBOOTISO' iso/EFI/BOOT/efiboot.img mmd -i iso/EFI/BOOT/efiboot.img ::EFI mmd -i iso/EFI/BOOT/efiboot.img ::EFI/BOOT mcopy -i iso/EFI/BOOT/efiboot.img iso/EFI/BOOT/BOOTX64.EFI ::EFI/BOOT/BOOTX64.EFI cd iso xorriso -as mkisofs -V 'FOGPROJECT' -e EFI/BOOT/efiboot.img -no-emul-boot -o ../fos-x86_64-efi.iso .
Same here, use the
grub.cfg
file George provided in his tutorial. But you need to add those two lines at the start for George’s config example to work in this setup:set root=(cd0) set prefix=(memdisk)/boot/grub
Every time you change the contents of
grub.cfg
you need to run all the commands starting fromgrub-mkstandalone
again.Resouces used:
https://willhaley.com/blog/custom-debian-live-environment-grub-only/
https://github.com/syzdek/efibootiso
https://github.com/linuxkit/linuxkit/blob/master/tools/mkimage-iso-efi/make-efi
https://unix.stackexchange.com/a/611846 -
@sebastian-roth Thank you! This looks promising. I will give it a shot on Monday.
-
@sebastian-roth I used the grub-mkrescue method and it worked on the first attempt! This is very encouraging, and I am going to ask our lab tech to try this on the other problem systems.
I cannot thank you enough for your help.
-
@mechalas You are welcome.
From what I have seen in the verbose output of grub-mkrescue (just add
-v
as command line option) the ISO created might even boot on legacy BIOS systems as well. Not exactly sure though. -
@sebastian-roth as you suspected, this ISO image did boot both legacy and EFI. Which has been a boon.
I have used this ISO four times this week, and it has been a huge time-saver.