Skip to content

GRUB script to boot various Linux live CD/DVD ISO images

Notifications You must be signed in to change notification settings

Jimmy-Z/grub-iso-boot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

GRUB script to boot various Linux live CD/DVD images

Usage:

  1. Your target device, like a USB flash drive, should be formatted as FAT(32).
    • That's because (most) UEFI/EFI supports only FAT(32), if you target BIOS systems only, you can use ext4/btrfs/exFAT/NTFS, or whatever grub supports.
  2. Install GRUB(2, not legacy) on your target device: (assuming your USB drive is /dev/sdb and mounted on /mnt/usb/.)
    • For UEFI/EFI x64 systems: grub-install --target=x86_64-efi --boot-directory=/mnt/usb/boot /dev/sdb
    • For BIOS systems: grub-install --target=i386-pc --boot-directory=/mnt/usb/boot /dev/sdb
    • You can install both.
    • Alternative way for UEFI/EFI x64 systems:
      1. Build bootx64.efi:
        grub-mkimage -o bootx64.efi -O x86_64-efi -p /boot/grub \
        	boot linux linux16 chain normal configfile \
        	part_gpt part_msdos fat iso9660 udf \
        	test true keystatus loopback regexp probe \
        	efi_gop efi_uga all_video gfxterm font \
        	echo read help ls cat halt reboot
        
      2. Copy bootx64.efi to (USB)/efi/boot/.
  3. Put grub.cfg from this repository in (USB)/boot/grub/.
  4. Put image files in (USB)/boot/iso/.
  5. Boot from this device, that depends on your system/motherboard vendor.
    • On some modern PCs, you can press F12 to select from a list of boot devices during POST.
    • Configure BIOS/EFI to boot from this device.
    • More detailed document from Debian.

Currently supporting:

Some explanation:

GRUB is not able to do image boot on its own, the image boot procedure can be loosely described like this:

  1. GRUB loop mount the image, load the Linux kernel and initrd from it.
  2. GRUB boot the kernel, passing the initrd along with some parameters including the location of the image.
  3. Some script in initrd loop mount the image and continue the rest of the boot procedure.

So, if the initrd itself doesn't implement this mechanism, it won't work(hence the unsupported section).

And in step 2, different distributions tends to use different parameter schemes, this is where this script kicks in: it tries to determine the image vendor and feeds appropriate parameters accordingly.

Comparing with other methods:

The official way to make a bootable live USB drive suggested by most distributions is dd the image, those images are cleverly made FAT/ISO9660 hybrids so they work that way, depends on almost nothing, simpler to setup but also monogamy, destroys all data on the drive and the rest of the drive is not usable.

There are tools to put multiple distributions on a single USB drive, but mostly they are Windows only and they extract the image contents to the USB drive so they are slower, and needs to run the tool every time you want to add/remove a image.

Using this script, once the initial setup is done, you can simply copy/delete the image file, compatibility is not 100% but considerably usable.

Extra:

  • Debian Installer, initrd in the image doesn't support loop, but Debian provided an alternative initrd, copy vmlinuz and initrd from the hd-media directory to (USB)/boot/debian-installer/amd64/ and your choice of installer image (like this) to (USB)/ (not (USB)/boot/iso/).
    • Do not mix arch, for example you should use amd64 image with amd64 kernel and initrd.
    • Do not use live images.
    • Official document about this method is here.
  • EFI binary chainloading, simply copy to (USB)/efi/*/bootx64.efi, useful examples like:
    • UEFI shell, get the ShellBinPkg.zip, UEFI in most consumer boards doesn't come with shell, could be handy sometimes.
    • memtest86, you need to extract the disk image.

Notable unsupported

  • Proxmox VE, it's based on Debian but the boot script is their own, too bad this is one of my favorite distributions.
  • Mageia, doesn't have loop mount in initrd.
  • LXLE, it is actually a lubuntu derivative, while lubuntu works like other Ubuntu derivatives, it doesn't, strangely.

About

GRUB script to boot various Linux live CD/DVD ISO images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published