GRUB script to boot various Linux live CD/DVD images
- Install GRUB(2, not legacy) on your target device, like an USB flash drive
For UEFI/EFI x64 systems:
Target device MUST be formatted as FAT32
grub-mkimage -o bootx64.efi -O x86_64-efi -p /boot/grub \ boot linux linux16 normal configfile \ part_gpt part_msdos fat iso9660 udf \ test keystatus loopback regexp probe \ efi_gop efi_uga all_video gfxterm font \ echo read help ls cat halt reboot
For (Legacy) BIOS systems:
grub-install --target=i386-pc --boot-directory=/mnt/usb/boot /dev/sdb
assuming your USB drive is
/dev/sdband mounted on
- Put this
- Put images files in
- Change your UEFI/BIOS settings to boot from this device
- Debian Live, and some derivatives like:
- Ubuntu, and some derivatives like:
- Arch, and some derivatives like:
- Fedora, and its server counterpart CentOS Live
openSUSE, since Leap/42.1, openSUSE does not provide Live images anymore.
GRUB is not able to do image boot on its own, the image boot procedure can be loosely described like this:
- GRUB loop mount(the loopback command) the image, load the Linux kernel and initrd from it.
- GRUB boot the kernel, passing the initrd along with some parameters including the location of the image.
- Some script in initrd loop mount the image and continue the rest of 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:
Most Linux live images are hybrid FAT/ISO9660 so they can be written to a USB drive directly using dd and voila it's bootable, it's simpler if you want only one image, but 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.
- Debian Installer, funny the live initrd supports loop mount but installer initrd doesn't.
- Mageia, this is the only distribution that doesn't have loop mount in initrd on distrowatch top 10 list.
- LXLE, this is actually a lubuntu derivative, while lubuntu works like other Ubuntu derivatives.