1

background

(skip to header=problem if you're expert on LiveUSBs, ISOs, GRUB2, etc)

I'm setting up a multiboot/multiISO Linux LiveUSB as detailed here, which I intend for use on multiple hosts (I.e., any arbitrary PC I decide I need to boot). The process seems straightforward:

  1. Setup your development host: I.e., the box you'll use to create your LiveUSB, not that you'll boot with the LiveUSB.
  2. Get/make a USB drive that
    1. is sufficiently large for all the ISOs you want to boot
    2. is bootable
    3. has GRUB2 installed
  3. Put desired ISOs on it, in an easily-specified location.
  4. Edit /boot/grub/grub.cfg:
    1. Set global variables @ top (i.e., above the menuentrys), esp root
    2. Create one or more menuentrys for each ISO.

The main problem is, for each ISO, creating one or more menuentrys that appropriately boots it. This seems straightforward:

  1. Mount the ISO:
    1. Inspect the ISO's structure. Get its paths to its grub.cfg, initrd*, vmlinuz (or whatever it calls its GRUB config, initial RAMdisk image, and kernel image)
    2. Copy from the ISO's grub.cfg to your menuentry(s)
  2. Make each menuentry
    1. set the boottime path to the ISO
    2. create a loopback device using the ISO
    3. use a path to the loopback device instead of the path given in the ISO's grub.cfg, e.g.,
      1. initrd /casper/initrd.lz -> initrd (loop)/casper/initrd.lz
      2. linux /live/vmlinuz -> linux (loop)/live/vmlinuz
  3. Test your LiveUSB:
    1. While still mounted on your development host: grub-script-check for mental health :-)
    2. umount from your development host
    3. for each test host:
      1. attach to powered-down test host
      2. boot!

problem

Many ISOs have grub.cfgs that want to configure video before doing the "real" boot. They all do it slightly differently, so I put each ISO's video code inside its menuentry(s). However the ISO grub.cfgs I've worked with so far seem to do it more-or-less like this:

if loadfont /path/to/font/file ; then
  set gfxmode=auto
  insmod efi_gop
  insmod efi_uga
  insmod gfxterm
  terminal_output gfxterm
fi
# usually followed by more menu and background tweaking

The good news is, I can determine the boottime path to the fontfile--i.e., I can make loadfont happy. The bad news is, once inside the if block,

  • only 1 of the modules loads.
  • I get the same problem with ISOs that use Casper (e.g., Ubuntu-based Mint, LMDE1) or Debian Live (e.g., Clonezilla, LMDE2).

How do I make GRUB find all the modules?

example code

Note that Clonezilla's in-ISO /boot/grub/grub.cfg just forwards to its /EFI/boot/grub.cfg:

# This file is for compatibility to Ubuntu Linux's uEFI secure boot. 
# The real config file for grub is /EFI/boot/grub.cfg.
configfile /EFI/boot/grub.cfg

My LiveUSB's /boot/grub/grub.cfg (outside of all the ISOs) contains code like

# isofile_abspath==path to the ISO from the root of my LiveUSB.
set isofile_abspath='/ISOs/clonezilla-live-2.4.2-10-amd64.iso'
set root=(hd0,1)
loopback loop ($root)$isofile_abspath
...
set clonezilla_prefix='(loop)/EFI/boot'
...
set loadfont_fp="$clonezilla_prefix/unicode.pf2"
echo -e "About to 'loadfont $loadfont_fp' ..."
if loadfont "$loadfont_fp" ; then
  set gfxmode=auto
  echo -e 'about to `insmod efi_gop` ...'
  insmod efi_gop
  echo -e 'about to `insmod efi_uga` ...'
  insmod efi_uga
  echo -e 'about to `insmod gfxterm` ...'
  insmod gfxterm
  echo -e 'about to `terminal_output gfxterm` ...'
  terminal_output gfxterm
fi
echo -e 'Done loadfont.'

Results at boottime:

About to 'loadfont (loop)/EFI/boot/unicode.pf2' ...
about to `insmod efi_gop` ...
error: file not found.
about to `insmod efi_uga` ...
error: file not found.
about to `insmod gfxterm` ...
about to `terminal_output gfxterm` ...
error: no suitable mode found
Done loadfont.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.