0

Due to the increased file size of the Ubuntu LTS 22.04 Desktop image, Linux pen drive creators will soon feel the pain that comes with realizing that a single partition, FAT32 drive won't cut it for peeps wanting to boot this (and other) larger ISOs.

EFI necessitates at least two partitions, since EFI strictly and only supports FAT32.

So I formatted my USB stick to have a FAT32 partition for EFI and an EXFAT partition for storage and everything else like so:

  • (usb)E:/EFI/ - EFI folder on FAT32 partition
  • (usb)B:/boot/grub/ - grub install
  • (usb)B:/images/ - iso folder contains kali-linux-2023.3-live-amd64.iso and ubuntu-22.04.3-desktop-amd64.iso

I decided to keep the grub install on the same partition as the images, thinking that might help, but I also tried it with the grub installed on the FAT32 partition adjacent to the EFI location (it was E:/boot/grub/ instead) and that fails with the same error.

When booting from the USB stick, grub loads up fine. I see the 2 menu options appear and the custom grub theme stuff all shows up, but whether booting Kali or Ubuntu, all that happens is the correct splash screen and logo appear for a second and then I crash land into an initramfs (busybox?) shell that complains that it:

Could not find the ISO /images/ubuntu-22.04.3-desktop-amd64.iso

Here's the grub config in full (theme stuff not really needed but posting here for clarity's sake):

if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi

font=unicode

if loadfont $font ; then
  set locale_dir=$prefix/locale
  set lang=en_IN
fi

set gfxmode=auto
set gfxpayload=keep
set timeout=60
set default=0
set root="(hd0,msdos1)"

insmod all_video
insmod gfxterm
# insmod exfat
insmod part_msdos
insmod part_gpt
insmod regexp
insmod gettext
# insmod ext2
# insmod loopback
# insmod iso9660
insmod gfxmenu
insmod jpeg
insmod png

terminal_output gfxterm

loadfont ($root)/boot/grub/themes/stylish/dejavu_32.pf2
loadfont ($root)/boot/grub/themes/stylish/dejavu_sans_12.pf2
loadfont ($root)/boot/grub/themes/stylish/dejavu_sans_14.pf2
loadfont ($root)/boot/grub/themes/stylish/dejavu_sans_16.pf2
loadfont ($root)/boot/grub/themes/stylish/dejavu_sans_24.pf2
loadfont ($root)/boot/grub/themes/stylish/dejavu_sans_48.pf2
loadfont ($root)/boot/grub/themes/stylish/terminus-12.pf2
loadfont ($root)/boot/grub/themes/stylish/terminus-14.pf2
loadfont ($root)/boot/grub/themes/stylish/terminus-16.pf2
loadfont ($root)/boot/grub/themes/stylish/terminus-18.pf2

set theme=($root)/boot/grub/themes/stylish/theme.txt
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

export theme

# Ubuntu
menuentry "Ubuntu 22.04 Desktop" --class ubuntu --class linux {
    set root="(hd0,msdos1)"
    set isofile="/images/ubuntu-22.04.3-desktop-amd64.iso"
    # rmmod tpm
    insmod exfat
    loopback loop $isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} quiet splash toram tpm_tis.interrupts=0
    initrd (loop)/casper/initrd
}

# Kali Linux
menuentry "Kali Linux Live ISO" --class kali --class linux {
    set root='(hd0,msdos1)'
    set isofile="/images/kali-linux-2023.3-live-amd64.iso"
    rmmod tpm
    insmod ext2
    insmod loopback
    insmod iso9660
    loopback loop $isofile
    linux (loop)/live/vmlinuz boot=live components quiet splash toram noeject findiso=${isofile} tpm_tis.interrupts=0
    initrd (loop)/live/initrd.img
}

The grub docs are pretty clear that booting an ISO directly is possible (as it has been for quite some time) - I just can't for the life of me figure out what's wrong here.

To be clear - I don't want a tool or some solution that formats the USB and does this all automagically - I am asking what changes I need to make to the grub.cfg file in order to get a pre-existing, working grub USB install to boot my ISO images that live on the same USB drive.

Things I've already tried:

  • removing all the theme stuff (just in case)
  • installing the grub modules sooner (where the commented out lines are) instead of inside the menu entry
  • installing grub on the FAT32 partition alongside the EFI folder
  • removing the quotes around the iso file path
  • crying into my breakfast
  • using a different USB stick entirely
  • using a different computer/host machine

I am quite sure this isn't a hardware issue - it's a me-not-programming-grub-properly issue but I'm stumped, any help would be really appreciated.

Extra

I think I have the same issue as this guy, and I read through this answer but found no info there I hadn't already read or found elsewhere on the interwebs.

There does seem to be one hint on this dated post on pendrivelinux - a paragraph that stands out:

...grub can read from an exFAT filesystem using this method because it includes an exFAT driver module. However, to actually be able to boot from a Live ISO stored on the exFAT partition via loopback requires that the distribution also include a driver, and that the exFAT partition is automounted during boot. Otherwise, once the boot process has been handed over, the path to the ISO will no longer be found. When that happens, you'll likely be dropped into a BusyBox shell.

That could be what is happening but there's so many "ubuntu flash drive guides" out there that seem to use this exact method I guess I just assumed it would work, but is that not the case?

6
  • I doubt "Linux pen drive creators will soon feel the pain". The primary way to create a bootable pendrive from ISO was always "dd your ISO file to the flash, erasing whatever been there" and the problem you mentioned doesn't change it. And if you want persistent storage with Linux, just install it and don't boot from the flash every time. Commented Sep 20, 2023 at 7:22
  • Not that this really helps solve the question in in any shape or form, but FYI I will install Ubuntu onto my internal hard drive from this very USB the moment I can boot into it - I also just want to be able to keep the pen drive as an extensible boot stick that I can whack other distros onto.
    – GrayedFox
    Commented Sep 20, 2023 at 7:26
  • this exact method I guess I just assumed it would work, but is that not the case assume it would work for exfat? as in your have tried to include the driver in initrd like "this guy" or not? (btw, "this guy" didn't seem to get it actually included after all) either way, the quote is true, once you get pass grub, the early init of the distro handles the stuff and requires the corresponding kernel module to be builtin or loaded. (But there's this thing Ventoy you might want to play with. I have no idea what "trick" / "different way" it uses though.)
    – Tom Yan
    Commented Sep 20, 2023 at 12:04
  • 1
    exFAT it MS proiprietary, and requires fuse or other means to read it. It's not a good choice for boot partition. Consider ext4, unix.stackexchange.com/questions/422656/… Commented Sep 20, 2023 at 16:27
  • @DrMoishePippik to be fair though, exfat kernel driver has been mainline/upstream/in-tree for a while
    – Tom Yan
    Commented Sep 20, 2023 at 16:33

1 Answer 1

0

The problem was indeed the file system. I deleted the exfat partition and reformatted the USB stick like so:

  • (usb, FAT32) E:/EFI/ - EFI folder
  • (usb, FAT32) E:/boot/grub/ - grub install, moved back to FAT32 partition
  • (usb, EXT4) B:/images/ - ext4 partition (was exfat)
  • (usb, EXFAT) S:/ - reduced size exfat partition for Linux and Windows friendly file storage

The tricky part was getting the images from a Windows machine onto the ext4 partition which Windows has no built in support for but once I did that and updated the menu entries I could boot both Kali and Ubuntu.

# Ubuntu
menuentry "Ubuntu 22.04 Desktop" --class ubuntu --class linux {
    set root="(hd0,msdos1)"
    set isofile="/images/ubuntu-22.04.3-desktop-amd64.iso"
    insmod ext2
    loopback loop $isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} quiet splash toram tpm_tis.interrupts=0
    initrd (loop)/casper/initrd
}

# Kali Linux
menuentry "Kali Linux Live ISO" --class kali --class linux {
    set root='(hd0,msdos1)'
    set isofile="/images/kali-linux-2023.3-live-amd64.iso"
    insmod ext2
    loopback loop $isofile
    linux (loop)/live/vmlinuz boot=live components quiet splash toram noeject findiso=${isofile} tpm_tis.interrupts=0
    initrd (loop)/live/initrd.img
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .