If you want to know why I have this setup see How to boot an ISO in your hard drive using Grub.
Here I show you how to use one example of squashfs first and later one Ubuntu ISO.
My setup is an Arch Linux laptop using UEFI and systemd-boot. For grub see the other post.
Download the ISO file: grml.org.
First, you have to copy some files from the ISO.
To make this command easier to understand mount the ISO in some place and
$ mkdir /boot/grml $ cp boot/grml64small/vmlinuz boot/grml64small/initrd.img live/grml64-small/grml64-small.squashfs /boot/grml
And create the file
title Grml Live Linux linux /grml/vmlinuz initrd /grml/initrd.img options apm=power-off boot=live live-media-path=/grml/ nomce net.ifnames=0
For the full version the command is similar you only replace reference of small with full:
$ cp boot/grml64full/vmlinuz boot/grml64full/initrd.img live/grml64-full/grml64-full.squashfs /boot/grml
The entry file is similar as well but not identical. Make sure you have it updated.
With Ubuntu things are similar, you still need an
vmlinuz but this time we will use the ISO itself.
You will have to mount the ISO at least once to copy
After this initial setup, the updates are just copying the ISO to
/boot. (Optionally you can copy the other files again).
First copy the ISO to
Mount the ISO and
cd to its root (aka, mount point), then:
$ mkdir /boot/casper $ cp casper/initrd casper/vmlinuz /boot/casper
Create the file
title Ubuntu Linux linux /casper/vmlinuz initrd /casper/initrd options boot=casper iso-scan/filename=/ubuntu-20.04-desktop-amd64.iso noeject noprompt
Remember to update the last line with the correct name of your ISO.
And also remember the ISO is in
/boot but the other files are in
If you want even more convenience you can rename the ISO to
ubuntu.iso, this way whenever you update the ISO you don't have to update the content of the entry file as well.
For more options for casper see: https://manpages.ubuntu.com/manpages/xenial/man7/casper.7.html.