Ubuntu: Emergency LiveCD from harddisk (direct boot from iso file)

sudo su
 
URL=http://releases.ubuntu.com/20.04/ubuntu-20.04.1-desktop-amd64.iso
RELEASE=$(echo ${URL##*/} | cut -d "-" -f2)
wget http://releases.ubuntu.com/20.04/ubuntu-20.04.1-desktop-amd64.iso -O /boot/${URL##*/}
 
cat <<EOF>> /boot/grub/grub.cfg
menuentry "Ubuntu ${RELEASE} CLI" {
    loopback loop /boot/${URL##*/}
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/${URL##*/} init 2 --
    initrd (loop)/casper/initrd
}
 
menuentry "Ubuntu ${RELEASE} GUI" {
    loopback loop /boot/${URL##*/}
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/${URL##*/} toram --
    initrd (loop)/casper/initrd
}
EOF