1

I'm trying to boot from Live iso file (Kali Linux Specifically) that is located on an LVM partition via grub.

I've managed to load the kernel and initrd from iso file but cannot figure out how to mount the root partition. This is what i currently have in grub.cfg

menuentry "Kali Live ISO" --class gnu-linux {
  insmod lvm
  insmod ext2
  set root="lvm/Fedora-root"
  search --no-floppy --fs-uuid --set=root --hint=${root} 29e2f518-5fad-49c9-90ef-966b0c033c5e
  set isofile="/ISO/kali-linux-2019.1a-amd64.iso"
  loopback loop $isofile
  linux (loop)/live/vmlinuz boot=live iso-scan/filename=${isofile} noconfig=sudo username=root hostname=kali
  initrd (loop)/live/initrd.img
}

uuid above is uuid number of partition in question that the ISO file is located, obtained from blkid. I'm stuck here.

  • Try live-media=/dev/mapper/Fedora-root findiso=ISO/kali-linux-2019.1a-amd64.iso or findiso=/dev/mapper/Fedora-root/ISO/kali-linux-2019.1a-amd64.iso or both... – frostschutz Apr 30 at 23:18
1

You are probably stuck due to a misunderstanding.

Grub is inherently incapable of booting any ISO.

Yes, (within limits) Grub can decrypt encrypted devices, understand RAID and LVM, mount a plethora of filesystems, and even loop-mount ISO. But all of these fancy features have but a single purpose:

Load the kernel and initrd.

At the end of the day, Grub is still only a bootloader.

Once you are able to load the kernel and initrd, it does not matter what hoops you had Grub jump through. The result is utterly the same as if you copied those two files to a simple unencrypted /boot partition directly.

mount -o loop kali-linux-2019.1a-amd64.iso /mnt/iso
cp /mnt/iso/live/{vmlinuz,initrd.img} /boot/kali

Then boot it like this:

menuentry "Kali Live ISO" {
    linux kali/vmlinuz ...parameters...
    initrd kali/initrd.img
}

Identical to yours above provided those two files (vmlinuz and initrd.img) are the ones taken from the corresponding ISO file.


It's the same thing, really. Grub just wants these two files, no matter how. You can boot ISOs with any bootloader that can load kernel and initrd, none of this depends on Grub's fancy features (although it may simply be more convenient).

So Grub only loads the kernel, passes it some kernel parameters and the initrd, and that was it. Once the kernel is loaded, there is no LVM, there is no (loop) and no ISO. Whatever Grub did is gone and replaced with the kernel itself.


How, then, does the ISO boot?

It boots itself. That's why you have to pass the filename of the ISO as a kernel parameter, so it knows which file to look for. Well, even that could be optional, if the default filename were to be hardcoded in the ISO initramfs.

And then there is a bit of code in the ISO's initramfs that goes through all your storage devices, mounts all your filesystems, and searches for this file. And when it finds the file, it loop-mounts it.

And that's how it works, it's not Grub but the ISO itself that implements the functionality, and depending on this implementation (if there is an implementation at all - otherwise it won't work), it might or might not support locating this file on LVM logical volumes, or even support RAID and encryption.


For Kali specifically, I don't know if it's possible. I tried to read into Kali's initramfs code a little, and iso-scan/filename= does not seem to exist at all, instead it should be findiso=, and prepending it with a /dev/mapper/ path or suppling that separately with live-media= might enable LVM support.

But I haven't actually tried it myself and the initramfs is hard to decipher, so you'll have to experiment / investigate yourself or take this question to the Kali community.

Alternatively just put the ISO file in an easier to reach location (regular partition).

  • 1
    Tried what you said in previous comment, it worked ! I will post an answer now :) – Marko Todoric May 2 at 8:34
1

Like frostschutz said, appending live-media=/dev/mapper/Fedora-root findiso=ISO/kali-linux-2019.1a-amd64.iso to kernel command-line parameters worked. So this is how it looks the new menuentry that works

menuentry "Kali Live ISO - findiso" --class gnu-linux {
  insmod lvm
  insmod ext2
  set root="lvm/Fedora-root"
  search --no-floppy --fs-uuid --set=root --hint=${root} 29e2f518-5fad-49c9-90ef-966b0c033c5e
  set isofile="/ISO/kali-linux-2019.1a-amd64.iso"
  loopback loop $isofile
  linux (loop)/live/vmlinuz boot=live live-media=/dev/mapper/Fedora-root findiso=ISO/kali-linux-2019.1a-amd64.iso noconfig=sudo username=root hostname=kali
  initrd (loop)/live/initrd.img
}

Turns out that kali initramfs doesn't support iso-scan/filename= parameter.

-1

I confirm the possibility of boot of an ISO, on a logical volum with Grub 2.00. In my case, I have an unique partition MBR of type LVM,(the whole disk). I have only 2 LVs (boot and iso) and I can boot with this ubuntu-18.04.2-desktop-amd64.iso. Unlucky, due to a lack of capacity of casper (the livecd mechanism for ubuntu), I have fixed a file in the initramfs,(but without modify the iso).

For Kali, yes the last solution works, and it's more simple

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.