9

I want to create a USB stick that I can use to boot multiple iso files. I want to do this through uEFI.

The usb stick would look something like this:

/EFI
  /bootx64.efi
  /something.conf
/isos
  /foo.iso
  /bar.iso
  ...

Here, /isos holds a bunch of uEFI bootable iso files. From what I understand these isos have a /EFI/BOOT<some arch>.efi file that the uEFI booloader would normally execute.

On the drive /EFI/bootx64.efi is some to be determined efi booloader and /EFI/something.conf is its configuration file.

What I need is some uEFI executable that can somehow call /EFI/BOOT<some arch>.efi within one of the iso files. I don't know if this is theoretically possible.

I know that something similar can be done with GRUB2, but it requires specifying the linux image, its options and the initrd file. This is different from one iso to the other and sometimes, it doesn't work at all. My hope is that by calling /EFI/BOOT<some arch>.efi, I don't have to specify these and I can have one recipe to boot any iso image.

My question is: Is there a uEFI bootloader that can let me call an EFI executable that is located inside an iso file?

  • Short answer - No, there not a standalone UEFI bootloader that can let me call an EFI executable that is located inside an iso file. – fpmurphy Oct 24 '17 at 02:27

3 Answers3

4

This won't work for all ISOs, but you can use MEMDISK from syslinux to copy the ISO to memory as a RAMDISK image. BIOS calls will see the RAMDISK, and linux, too, will recognize the RAMDISK. To do this you will have to copy syslinux.efi and the associated files someplace onto your EFI system partition (ESP), like EFI/syslinux. Then in /EFI/syslinux/syslinux.cfg, create a bunch of memdisk memory options for your ISO files, along the lines of the examples on the MEMDISK page.

user3188445
  • 5,257
2

When you boot directly from an ISO, once the linux kernel is loaded, it will need to get the squashfs from inside the ISO. To do this, the linux kernel and scripts will need to mount the ISO as a loop device. To do this, it needs to know the path and filename of the ISO file. The full path is usually specified in the kernel parameters, e.g. iso-scan/filename=/images/ubuntux64.iso

Some Ubuntu ISOs contain a /boot/grub/loopback.cfg file and these expect a grub2 variable to have already been preset with the full path of the ISO file.

So, with these ISO files, we have a generic way of getting them to boot - just set up the grub2 variable with the full path of the ISO file and run the loopback.cfg file.

So it is possible to have a grub2.cfg file which lists all the ISO files in the /images folder and allows the user to pick one of them and boot to it. The only problem is that they need to contain the /boot/grub/loopback.cfg file and very few non-Ubuntu ISOs do!

If only more distro developers would include a loopback.cfg file inside their ISOs, then what you want would be possible!

http://www.rmprepusb.com/tutorials/136_uefi_ubuntu may help. Also http://rmprepusb.blogspot.co.uk/2017/02/make-generic-grub2-boot-menu-using.html

SSi
  • 193
1

Yes and no. You can boot to a pre-boot environment (grub, iPXE and etc) but doing so is really just going to complicate things. Most live discs don't have the files you're talking about - not exactly. What most iso-hybrid disks do is something like what is described in the other answer here - they mount an image file where the real executables are on a loop device in a ram-disk and afterward call up that kernel. The point of all of that complication is supposed to be conpatibility with BIOS systems. If that is not a concern of yours, you'd likely do better just to pull a few files from each iso and boot dirwctly. On an EFI system - because the firmware is your bootloader in that case.

So what you want is a FAT-formatted USB stick. You can mount the isos in question, find their x86 .sfs root image file, find their initramfs and kernel (you'll probably need to loop mount another image within the iso mount) - and that's about it. The linux kernel is an EFI-executable - you don't need a bootloader, because the firmware can exec your kernel. And the kernel's first root file system is mounted from the initramfs image. It's next is the .sfs archive. That's how it works.

It's kind of vague here, but there is a pretty detailed walkthrough of doing a similar thing with an Arch Linux installation media here.

(the process differs very little by distribution in general)

mikeserv
  • 58,310