Ubuntu – BIOS/UEFI Template Image for Booting ISO Files

live-usbpersistenceusbusb-installation

The creator of mkusb has released an Template Image for creating BIOS/UEFI boot partitions on a USB.

How can I use this image to boot ISO files from a USB?

Best Answer

  • Booting ISO Files with mkusb BIOS/UEFI GRUB Template Image

    There are a few pre-built programs available for multibooting Linux systems: MultiBootUSB, Ventoy and YUMI. The inner workings of these tools is not very transparent.

    Now it is easy to build an ISO booting USB that works in BIOS and ISO mode from scratch.

    There are several versions of the mkusb BIOS/UEFI GRUB template.

    https://phillw.net/isos/linux-tools/uefi-n-bios/dd_grub-boot-template-for-uefi-n-bios.img.xz For use in Windows 10 and in Linux.

    https://phillw.net/isos/linux-tools/uefi-n-bios/mkusb_grub-boot-template-for-uefi-n-bios_fat32_4GB_use-in-wins.img.xz For use in Windows 7 thru 10, it has a 4GB FAT32 No 1 partition that is accessible in older versions of Windows or IOS.

    MD5SUM's can be found here: https://phillw.net/isos/linux-tools/uefi-n-bios/grub-boot-templates-for-uefi-n-bios.md5.

    Basic ISO Booter (Min 4GB USB)

    • Flash mkusb_grub-boot-template-for-uefi-n-bios_fat32_4GB_use-in-wins.img to a USB using Rufus, Etcher, Gnome-Disks, mkusb or etc. (Use 7zip to extract from xz if necessary).

    • Copy the ISO file for any flavor of Ubuntu (Kubuntu, Lubuntu ... Xubuntu) or Linux Mint* to the USB.

    • Rename the ISO file to ubuntu.iso.

    • Boot the USB and confirm that everything works.

    Linux Mint, Elementary OS and some flavors of Ubuntu may require initrd.lz rather than initrd in grub.cfg.

    Basic ISO Booter with Persistent Partition Alt1 (Min 4GB USB) Only one persistent partition is allowed per Computer.

    • Create Basic ISO Booter above.

    • Boot USB, open GParted and format empty space to the right of the boot partitions as ext4, label it casper-rw.

    Basic ISO Booter with Persistent Partition Alt2 (Min 4GB USB)

    • Create Basic ISO Booter above.

    • Boot the USB, at the boot menu select live-only option and press e to edit.

    • Use the arrow keys to get to the end of the linux line, (one space after the word nopersistent). and type toram then press F10 to boot.

    • In Terminal type sudo umount -lrf /isodevice to unmount the USB.

    • Open GParted. Move EFI boot partition 1MB from right side. Move BIOS boot partition next to it. click apply, Adjust Partition No1 size as required.

    • Create a new ext4 partition in the unused space, label it casper-rw

    • A persistent partition labeled home-rw can also be created, It is similar to a /home partition in a Full install.

    • Boot the USB using the persistent menuentry option.

    Named ISO Files

    • Boot the USB and edit grub.cfg using

      sudo gedit -H /media/ubuntu/usbboot/boot/grub/grub.cfg
      

      Add proper ISO names, (and path), as shown below. Note: Using /etc/grub.d/40_custom to edit grub.cfg does not work with ISO files.

      menuentry "ubuntu-20.04.1-desktop-amd64.iso live-only" {
         set isofile="/ubuntu-20.04.1/ubuntu-20.04.1-desktop-amd64.iso"
         loopback loop (hd0,1)$isofile
         linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject quiet splash maybe-ubiquity nopersistent
         initrd (loop)/casper/initrd
      }
      

    ISO Multi-Booter (Min 8GB USB)

    • Boot toram and move boot partitions as above using GParted.

    • Resize FAT32 partition to fill empty space.

    • Copy preferred Ubuntu flavors (Kubuntu, Lubuntu ... Xubuntu) ISO's to USB.

    • Edit grub.cfg providing a uniquely named menuentry for each ISO.

    ISO Multi-Booter with Multi-Persistence (16GB+ USB)

    • Create multi-booter as above.

    • Add a uniquely named folder to a FAT32 partition for each ISO file requiring persistence if not already there.

    • Add a persistence file labeled writable to each folder.

    • Add a persistence file labeled home-rw to each folder as desired.*

    • Edit linux line of each persistent menuentry adding persistent-path=foldername

    Example: linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject quiet splash fsck.mode=skip persistent persistent-path=ubuntu-20.04.1

    To create persistence file:

    sudo dd if=/dev/zero of=casper-rw bs=1M count=512
    sudo mkfs.ext4 -F casper-rw
    
    • (Replace 512 with the "size in MB" you require, max 4000)
    • For Ubuntu 20.04 and later replace casper-rw with writable
    • For a home-rw partition replace casper-rw with home-rw

    Additional Tweaks

    • Booting to RAM: Add toram at the end of the grub.cfg menuentry linux line.

    • Eliminating Disk Check: Add fsck.mode=skip at the end of the grub.cfg live-only menuentry linux line.

    • Eliminating Try/Install screen: Remove maybe-ubiquity from the grub.cfg live-only menuentry linux line.

    • Safe Graphics Mode: Add nomodeset at the end of the grub.cfg menuentry linux line.

    • To watch boot progress remove quiet splash from the menuentry linux line.

    • Personalize a persistent ISO. Go to settings/Users and add a New User and a password. You can make new users for each persistent ISO.

    • Additional menuentries see: https://help.ubuntu.com/community/Grub2/ISOBoot/Examples

    • When booted from the USB, data copied to the disk is located in the isodevice folder.

    • There seems to be some problem with home-rw files, persistent-paths and Ubuntu 20.04 right now.

    These templates require editing to work with other Linux distros

    • Some other Linux distros have much in common with Ubuntu, but the internal boot structure is usually different from standard Ubuntu and the Ubuntu family flavours, so it would be necessary to tweak the grub configuration (in the menuentries of grub.cfg).
    • mkusb can create live-only as well as persistent live drives from several non-Ubuntu ISO files, for example Debian Live and Linux Mint.

    Additional Menuentries for some popular Linux distro's:

    Debian Live

    menuentry "debian-live-10.5.0-amd64-gnome" {
        set isofile="/debian-live-10.5.0/debian-live-10.5.0-amd64-gnome.iso"
        loopback loop (hd0,1)$isofile
        linux (loop)/live/vmlinuz-4.19.0-10-amd64 boot=live findiso=$isofile persistence persistence-path=debian-live-10.5.0
        initrd (loop)/live/initrd.img-4.19.0-10-amd64
    }
    

    To create persistence file:

    sudo dd if=/dev/zero of=persistence bs=1M count=512
    sudo mkfs.ext4 -F persistence
    

    then mount it

    mkdir perst
    sudo mount persistence perst
    

    Create a persistence.conf file

    echo / union >persistence.conf
    echo >>persistence.conf
    

    Move it to the perst directory.

    And unmount:

    sudo umount perst
    

    To create persistence partition:

    Create an ext4 partition, label it persistence and drop a persistence.conf file into it.