A FOB STORY: some notes on bootable flash drives

Booting ISOs and other image files

Probably the simplest way to set up a single-boot fob (or begin configuration of a multi-boot fob) is to just copy the contents of a Ubuntu live CD or ISO to the fob.  Either boot that in UEFI mode or also install grub2 stand-alone for legacy booting.

In that situation, the /boot/grub/grub.cfg boot stanza would look something like this:

menuentry "Try Ubuntu without installing" {
    set gfxpayload=keep
    linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --
    initrd /casper/initrd.lz
}

Another approach is to install grub2 stand-alone (for UEFI and/or legacy booting) and then copy the Ubuntu ISO directly to the fob.  In this case we’re copying the ISO file, not its contents.

It’s a major advantage to use ISO files for multiboot flash drives.  Trying to overlap two – or more – distros in the same place by copying ISO or CD contents to the flash would be impossible.  With ISOs, the seperate files don’t interfere with each other.

Another nice thing: the ISOs are available on the flash drive for CD burning.  If a machine won’t – or can’t – boot the flash drive, one can make a CD and try that.

Grub2 can loop-mount an ISO and boot its contents.  To do that, use a boot stanza like this:

menuentry "Ubuntu 14.04.1 64-bit Desktop ISO" {
    set isofile="/bootable/iso/ubuntu-14.04.1-desktop-amd64.iso"
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile noeject noprompt splash --
    initrd (loop)/casper/initrd.lz
}

Note:  using an ISO file booted in this way does not allow booting in secure boot mode.

[Update 2020.09.13] persistence and ISO booting:

Persistence didn’t work with Ubuntu 20.04.  Just about went up in smoke trying to figure it out.  The name of the persistence file has changed from casper-rw to writable.

There’s a work-around that gets loop-mounted ISOs to boot in 20.04.  Add rmmod tpm to grub.conf as shown below:

if loadfont /boot/grub/font.pf2 ; then
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm

# try to work around ISO loop boot problem
rmmod tpm
fi

Another note:  the above are examples of booting a 64-bit distro.  If booting a 32 bit Ubuntu, the linux file will be vmlinuz – without the .efi extension.  That may change in the future if Ubuntu implements 32-bit UEFI compatibility.

Grub2 can also boot some other image files directly.  This is what the boot stanza for legacy memtest86 looks like.  See later page “Chainloading…” for booting memtest in UEFI mode.

menuentry "Memtest 86+ V5.01 legacy boot" {
    linux16 /bootable/images/memtest86+-5.01.bin
}

Some ISOs and other image formats may require an external tool: memdisk from the Syslinux site.  To date, memdisk works only in legacy mode.  Memdisk can be extracted from the syslinux zip file.  It’s in /memdisk/ in older versions, and /bios/memdisk/ in newer versions.

For instance, to boot an Acronis ISO:

menuentry "Acronis 2013 6514 ISO" {
    linux16 /boot/isolinux/memdisk-6.02 iso raw
    initrd16 /bootable/iso/ATIH2013_6514_en-US.iso
}

[Update 2018.05.01]  the above will only boot in legacy mode even if the ISO is UEFI-bootable when installed stand-alone.  The below is an example of how to boot an Acronis ISO in UEFI or legacy mode.

menuentry "Acronis 2018 9207 ISO 64 Bit Mode UEFI  and Legacy" {
set quiet=1
set gfxpayload=1024x768x32,1024x768
set mbrcrcs=on
set isofile="/bootable/iso/AcronisBootableMedia2018_9207.iso"
search --set -f $isofile
loopback loop $isofile
# edit: lang=13 is asian # linux (loop,msdos1)/dat10.dat lang=13 quiet force_modules=usbhid
linux (loop,msdos1)/dat10.dat quiet force_modules=usbhid
initrd (loop,msdos1)/dat11.dat (loop,msdos1)/dat12.dat
boot
}

Note:  the paths to memtest and to the ISO and image files in the above examples are particular to my setup.  Yours will look different depending on how you choose to organize the files and folders.

Also note: there are additional examples of ISO and other image booting in the grub.cfg sample at the end of this article.

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to A FOB STORY: some notes on bootable flash drives

  1. Pingback: FOB Story II | GeezBlog

Leave a Reply

Your email address will not be published. Required fields are marked *