5

During bootup, I enter the grub2 command-line by pressing c on the Grub menu.

When I type the following command...

loopback loop (hd0,gpt2)/ubuntu-19.10-desktop-amd64.iso

...grub hangs, there is no more output or activity on the terminal, and eventually the laptop fans spin up because the laptop gets hot.

The path (hd0,gpt2)/ubuntu-19.10-desktop-amd64.iso is valid on my system.

I get the same result, regardless of which ISO I use, and I have verified the checksums of the ISOs.

I am experiencing this in Ubuntu 19.10 and did not have this issue in prior Ubuntu releases. The version of grub2-common I have is 2.04-1ubuntu12.

How can I get the loopback grub command to work? (For example, do I need to load specific modules or enter other commands prior to executing loopback?)

(Also, please add a comment if you also experience this issue on 19.10; I'd like to determine if this is specific to my install, or if this is a larger issue?)

(Please note, this question is related to another question about booting to an ISO on disk I have posted, but I beileve they are sufficiently different to warrant a separate post).

Enterprise
  • 12,002
  • 11
  • 60
  • 105
  • Loopback loop has worked for me dozens of times with 19.10: https://askubuntu.com/questions/1183191/handmade-live-usb-multisystem?noredirect=1#comment1978607_1183191 . Note that Ubuntu uses **vmlinuz** not vmlinuz.efi and **initrd** not initrd.lz with 19.10. I use **set root=(hd0,1)** – C.S.Cameron Nov 04 '19 at 04:16
  • 1
    Ok, so there must be something wrong with my installation. I am using “vmlinux” and “initrd”. After I execute set root=(hd0,gpt2), what should my loopback command look like? Do I reference root in that command? – Enterprise Nov 04 '19 at 04:41
  • 1
    Yes I saw that in your referenced question. What partition is your ISO file on? If on partition 2, (gpt2), have you tried using just (hd0,2)? When I have difficulty finding the boot partition I enter an "e" at grub and systematically edit my "set root=" and press F10 until I get a clue. My full grub.cfg is shown on the page I referenced. (although I often use a mkusb foundation where the hard work is done for me). – C.S.Cameron Nov 04 '19 at 06:16
  • In the past, both (hd0,2) and (hd0,gpt2) worked interchangeably. I am able to navigate to the *.iso file on my 2nd partition using the ls command in grub. (If I put something else, or if I incorrectly name the *.iso, grub gives me a kernel not found error (or similar message). So I am confident that "(hd0,2)/ubuntu-19.10-desktop-amd64.iso" or "(hd0,gpt2)/ubuntu-19.10-desktop-amd64.iso" are the correct values to use. But grub just hangs as soon as it encounters the loopback command without printing any output. – Enterprise Nov 04 '19 at 20:53
  • 3
    I had same issue & created bug. Issue is with grub 2.04. I tried booting Focal with grub installed from 19.10. Double & triple checked paths & configuration file. Reinstalled UEFI from 18.04, so grub 2.02 and same boot stanza worked Error was "Out of Memory" and "no server" https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311 – oldfred Nov 05 '19 at 14:06
  • I just subscribed to Launchpad bug 1851311. – Enterprise Nov 07 '19 at 02:17
  • Note: I tried installing the `grub2-common` and `grub-common` `*.deb` packages from Ubuntu 18.04 (versions 2.02) into 19.10, but I couldn't get it to work. – Enterprise Nov 07 '19 at 02:25
  • @oldfred : does this affect both BIOS and UEFI booting or just UEFI? – C.S.Cameron Nov 07 '19 at 04:14
  • I have a BIOS based PC using the exact same setup, but I am able to boot into the *.iso on disk. So I think this only impacts UEFI systems. – Enterprise Nov 07 '19 at 04:26
  • Have not used BIOS to boot for about 6 years. But based on above, it then seems to be UEFI only issue. – oldfred Nov 07 '19 at 14:17
  • @PJ Singh : I noticed that I had been using mkusb installed in 18.04 to make my ISO booter foundation, (as below), thus the grub 2.02 menu. Installed mkusb into one of my 19.10 disks and made another ISO booter, now have grub 2.04 menu, but it still boots ISOs fine in BIOS mode. I think you are right about it being a UEFI thing but do not have access to a UEFI computer to test it with at the moment. – C.S.Cameron Nov 08 '19 at 04:27

5 Answers5

5

There is a workaround to Ubuntu Bug #1851331...

Disable the TPM module by adding rmmod tpm as the 1st command in your grub config file.

For example, here is my /etc/grub.d/40_custom file...

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "Install" {
    rmmod tpm
    set isofile="/ubuntu.iso"
    loopback loop (hd0,2)$isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
    initrd (loop)/casper/initrd
}

Remember to update grub after making the change.

sudo update-grub
Enterprise
  • 12,002
  • 11
  • 60
  • 105
  • This worked for me on UEFI GRUB 2.04 from Xubuntu 20.04. I couldn't even `ls` the iso file itself without GRUB freezing without `rmmod tpm` – pizzapants184 Jun 09 '20 at 07:24
1

Grub.cfg for loop mounting ISOs

if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

set timeout=5

menuentry "ubuntu-19.10-desktop-amd64.iso" {
    set root=(hd0,1)
    set isofile="/isos/ubuntu-19.10-desktop-amd64.iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile persistent persistent-path=/persist-1/ splash --
        initrd (loop)/casper/initrd
}
menuentry "lubuntu-16.04.3-desktop-amd64.iso" {
    set root=(hd0,1)
    set isofile="/isos/lubuntu-16.04.3-desktop-amd64.iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile persistent persistent-path=/persist-2/ splash --
        initrd (loop)/casper/initrd.lz
}

Grub.cfg example that works for me.

I just edited the grub.cfg that I copied from the ISO.

There are many reasons a persistent USB might not boot including:

  • Bad MD5SUM / Corrupt ISO file

  • Incorrect path to ISO in grub

  • Incorrect root partition

  • Casper-rw partition not ext file system

  • Incorrect persistent-path, (if used), in grub

  • Casper-rw partition reused from previous version

  • Casper-rw file full

  • Modified or corrupted ISO9660 partition

  • Incorrect file type for vmlinuz and initrd (.efi and .lz)

  • Grub menuentry not suiting OS

  • USB removed before ISO file is completely copied

  • Problems with BIOS or UEFI boot partitions or files.

  • USB not set as first hard drive in grub

  • Bad flash drive

  • Bad USB socket

  • Not enough RAM

  • Incompatible computer CPU

  • Incompatible computer GPU

Please let me know of any reasons I have missed.

C.S.Cameron
  • 18,890
  • 10
  • 64
  • 105
  • Thanks for this. I exited to the grub command line, and typed all of the commands inside the if statement above. I also set the menu color variables as shown, for good measure. Then I typed ‘set root=(hd0,2)’. Then I typed ‘set isofile=“/ubuntu-19.10-desktop-amd64.iso”’. I used tab completion, so the isofile name was correctly typed. So far so good. Then I typed ‘loopback loop $isofile’.... Grub just hung. No message, no error. Grub terminal is frozen. :( – Enterprise Nov 04 '19 at 21:13
  • What does the `boot=casper` option specifically do? – Luis A. Florit Jun 07 '23 at 00:57
1

mkusb simple ISO booter

If your ISO booter is still not working, here is a method that only takes a few minutes

  • Create a Persistent Drive using mkusb using all defaults.

  • Open GParted and delete the ISO9660 partition 4 and expand the casper-rw partition 5 into its space.

GParted Mods

  • Create a folder named isos in usbdata partition 1 and add an ISO.

  • Edit /boot/grub/grub.cfg in usbboot partition 2 overwriting the existing menuentries with:

.

menuentry "ubuntu-19.10-desktop-amd64.iso" {
    set root=(hd0,1)
    set isofile="/isos/ubuntu-19.10-desktop-amd64.iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile persistent splash --
        initrd (loop)/casper/initrd
}

If you use 18.04 when making your mkusb foundation then the drive should use grub 2.02 to boot the 19.10 ISO. See sudodus comments How to downgrade grub from 2.04 to 2.02 on ubuntu 19.04?

C.S.Cameron
  • 18,890
  • 10
  • 64
  • 105
  • I am rather sure that @oldfred is right, there is a bug affecting grub-n-iso booting. But mkusb's grub booting into a partition with an image of the iso file works (also in 19.10 and focal). This is when grub 2.04 is used. **But it might work, if you select 'upefi' (usb-pack-efi) in the settings menu of mkusb** for the boot system, because it is an older grub version. I suggest that you try that :-) – sudodus Nov 06 '19 at 20:58
  • @sudodus: I have made and tested ISO booters similar to above and above made manually with 19.10 about twenty times in the past week, they all work with BIOS, unfortunately the power brick to my UEFI computer is still plugged into the wall half way around the world. – C.S.Cameron Nov 07 '19 at 04:01
  • 1. Interesting :-) It seems that grub-n-iso works in BIOS mode, but not in UEFI mode. I will do some testing of that; 2. But right now I am busy with the new methods to create persistent live drives, that are possible due to the new feature alias removed bug in casper of Ubuntu 19.10. Have you tried yet to 'only' edit the iso file and clone it and let the live Ubuntu system create a paritition for persistence automatically in the unallocated drive space behind the cloned system? – sudodus Nov 07 '19 at 12:42
1

Similar issue I think: I use live Ubuntu as the base for my "Swiss Army" flash drives and external SSDs. I've been able to loop and boot a variety of Linux and other ISOs for some time.

If I use 19.04 for my base "install" - actually just files copied to flash - I can boot ISOs. If I use 19.10 I get a black screen hang. Three-fingered-salute will reboot the test laptop but actual booting of the ISO doesn't seem to proceed.

Example of what I've been doing: http://www.beezmo.com/geezblog/?p=1955

Sample stanza that works if 19.04 is the base but not if 19.10 is:

menuentry "Ubuntu 16.10 64-bit Desktop ISO" {
    set isofile="/bootable/iso/ubuntu-16.10-desktop-amd64.iso"
    loopback loop $isofile
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile noeject noprompt splash --
    initrd (loop)/casper/initrd.lz 
}

I'd stick with 19.04 but since 17.x if I enable persistence snapd burns all my CPU cycles and is unusable. 19.10 seems to have fixed that.

[edit to add] New here and haven't found my way around the editor. Sorry about the formatting :(

[further edit to add] And I guess this should have been a comment, not an "answer". I'll catch on eventually...

Bill W
  • 11
  • 3
  • Please click 'Affects me too' at the [bug report](https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311) by @oldfred. – sudodus Nov 06 '19 at 20:53
  • Did that. Thanks. – Bill W Nov 06 '19 at 22:24
  • Also seems that things work as expected in BIOS mode but not in UEFI mode. My external drives need to be able to boot in either, and have usable persistence. – Bill W Nov 07 '19 at 17:54
  • Is it possible to "borrow" a previous grub version - if it's grub that's buggy - and use it in a 19.10 *live* setup - and also have it install the legacy components via grub-install? – Bill W Nov 07 '19 at 17:57
  • Is it important, that you boot via 'grub and iso' or would it work with some other kind of system, for example to let mkusb install persistent live systems in your external drives? This method works with current Ubuntu versions including the developing Focal Fossa to become 20.04 LTS. An alternative would be to install a small system, which is old enough to have grub 2.02, and let its grub version manage booting of all installed internal and external systems as well as grub and iso systems simply by running `sudo update-grub` and have a `40_custom` file for the grub and iso systems. – sudodus Nov 07 '19 at 19:43
  • 1
    I'm using the "old system" approach now for essentially a stand-alone grub, and use it to boot later versions. It's handier and quicker though if the live "install" is actually a later version that I can use directly. Since there's a persistence problem I've been running 16.10 as my primary. Not ideal, but usable. Ideal would be 19.10 as the base, since it fixes the persistence bug. Thanks! – Bill W Nov 07 '19 at 22:23
  • 1
    @Bill W : If I make my ISO booter foundation, (as above), using mkusb installed in 18.04 the disk boots with grub 2.02, but if I make the foundation using mkusb installed in 19.10 the disk boots with grub 2.04. I spent a long time yesterday trying to figure out how to downgrade grub 2.04 to 2.02. – C.S.Cameron Nov 08 '19 at 04:39
-1

I also could not loopback iso.
I mounted iso and copied all files and directories to (hd0,gpt7).
Then rebooted PC and typed like below on grub command line.

set root=(hd0,gpt7)
linux /kernel
initrd /initrd.img
boot

It worked!
Even thou I could not loopback iso, I could same thing as booting from iso.

user645265
  • 29
  • 2