In the history, I can use iso_scan or loopback.cfg to boot:
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=${isofile} verbose
initrd (loop)/casper/initrd*
Or
loopback loop "$isofile"
root=(loop)
configfile /boot/grub/loopback.cfg
loopback --delete loop
The 20iso_scan report it cannot mount /dev/sr0 and cannot find the (hdx,gpt)/...iso
but the iso apparently is there otherwise, we cannot load the initrd and vmlinuz.
The second method, try to use the loopback.cfg come from the cd itself. However, it yield /init. line49: can't open /dev/sr0: No medium found
.
Any idea, what is the correct way to do it nowadays?
There should be a way to directly give the squash file paths already when I loop mount it? why it needs to scan the iso and mount again?
update
now I understood more about the livecd boot procedure.
- After we call the linux and initrd, the kernel take the ownership. Thus all the loopback devices created inside the grub are invisible to kernel.
- The kernel will reinitiate everything like it sees them the first time.
- The squash mount happens inside the kernel. At this time kernel can see the actual iso file on the real disk. It can mount the iso file and unpack the squashfs then.
However, the bootloader should still be able to give the kernel a ram disk as the initrd command. Ideally a bootloader should create a ram disk from squashfs (loopback does not create ram disk). Then kernel can mount it as a device. Or the bootloader may inject the entire iso into the initramfs. Some tool can already partially do that: ipxe's initrd.magic module for example. grub so far does not have this feature nor plan to provide one.
iso-scan/filename
is for casper script in kerenl environment. But I gave it the grub path with(dev, part)
prefix. I just strip that then it progressed more. Though it still report file is broken. I figured out the casper need mount all partitions it sees and then find the file. By accident I has another partition contains a broken iso with same path name. After removing that, it works. If you can emphasize this part in your answer, I shall accept it. – Wang Oct 24 '22 at 13:31