Creating a multiboot Ubuntu boot USB with UEFI support
April 30, 2016

People often waste a lot of space on their Ubuntu live USBs. An average Ubuntu ISO is only 1.3 GB. This post will teach you how to create a multi-boot USB flash drive.

First, you need to plug in a USB drive with at least 3 GB of free space. It will not be wiped, so it can still have other stuff on it.

Next, open a terminal in your USB drive. On most distros, just go to the USB drive in the file manager, right click, then click “Open in terminal” or something similar.

Then, type the following commands, and press enter after each one. MAKE SURE YOU ARE IN THE ROOT OF YOUR USB DRIVE:

mkdir -p boot
mkdir -p iso/ubuntu
sudo grub-install --target x86_64-efi --efi-directory=$PWD/ --boot-directory=$PWD/boot/ --removable
touch boot/grub/grub.cfg

After it finishes, you need to download the Ubuntu ISOs of your choice into the iso/ubuntu folder in your USB drive.

Then, open the grub.cfg file in the boot/grub folder in your USB drive in a text editor. Put entries for each ISO in the following format:

menuentry 'your-title' {
    set isofile='/iso/ubuntu/iso-name.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

Replace your-title with any name you want for that entry, and replace iso-name.iso with the filename of the ISO you downloaded. Do this for each ISO.

When you are done, your file should look something like this:

menuentry 'Kubuntu 16.04 desktop amd64' {
    set isofile='/iso/ubuntu/kubuntu-16.04-desktop-amd64.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

menuentry 'Lubuntu 16.04 desktop amd64' {
    set isofile='/iso/ubuntu/lubuntu-16.04-desktop-amd64.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

menuentry 'Ubuntu 16.04 desktop amd64' {
    set isofile='/iso/ubuntu/ubuntu-16.04-desktop-amd64.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

menuentry 'Ubuntu GNOME 16.04 desktop amd64' {
    set isofile='/iso/ubuntu/ubuntu-gnome-16.04-desktop-amd64.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

menuentry 'Ubuntu MATE 16.04 desktop amd64' {
    set isofile='/iso/ubuntu/ubuntu-mate-16.04-desktop-amd64.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

menuentry 'Xubuntu 16.04 desktop amd64' {
    set isofile='/iso/ubuntu/xubuntu-16.04-desktop-amd64.iso'
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash locale=en_CA.UTF-8
    initrd (loop)/casper/initrd.lz
}

Now, eject your USB drive.

You now have a multi-boot UEFI Ubuntu USB drive!

Patrick G
Patrick G
I like to write code. I love open source software. I like to self-host stuff.