8

tl;dr - Is it possible to boot from a .iso file that is located in an unencrypted lmv2 logical volume? How?

I'm trying to set this up in a VirtualBox VM before I do it for real with my laptop. I have the following set up:

  • 4 gpt partitions
    • gpt1 - 2M ef02 bios boot
    • gpt2 - 5G unencrypted non-lvm, for misc data,iso's, etc.
    • gpt3 - 5G unencrypted lvm, for /boot,iso's, etc.
    • gpt4 - remaining, lvm, encrypted with dm-crypt/luks, for root,swap,home,etc.
  • in gpt2, I have copies of current Arch and Xubuntu iso's
  • in gpt3, I have an lvm2 lv with the same copies of the same iso's

I have the following working:

  • in gpt4, functioning installs of Arch and Xubuntu (and would like to add other distro's in other logical volumes at some point)
  • grub2 installed from Arch on /dev/sda
  • using grub2's configfile command, can switch and boot from both distro's grub2 menu's
  • can boot iso's from grub menu from non-lvm gpt2

What I would like to do is boot from the iso's in gpt3 lvm (and ultimately, not even have the non-lvm gpt2 partition at all).

My grub entry is:

menuentry "Xubuntu ISO" {
  set isofile="/xubuntu-12.04.1-desktop-amd64.iso"
  # from non-lvm
  loopback loop (hd0,gpt2)$isofile
  # from lvm
  #loopback loop (vgboot-iso)$isofile
  linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
  initrd (loop)/casper/initrd.lz
}

The 2 loopback lines point to 2 different copies of the same iso. I've verified at the grub command line that both loopback lines work.

When booting from the iso in the non-lvm partition, everything works fine.

When booting from the iso in the lvm partition, the boot starts, and eventually gets this error:

(initramfs) /scripts/casper-premount/20iso_scan: line 46: can't open /dev/sr0: No medium found

For the arch entry:

menuentry "Arch ISO" {
  set isofile="/archlinux-2012.09.07-dual.iso"
  loopback loop (hd0,gpt2)$isofile
  #loopback loop (vgboot-iso)$isofile
  linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201209 img_dev=/dev/sda2 img_loop=$isofile earlymodules=loop
  initrd (loop)/arch/boot/x86_64/archiso.img
}

booting from gpt2 iso works, but I don't know what to change the "/dev/sda2" to for lvm boot.


EDIT: Can this be done? For any current Linux distro's official .iso file? Fedora? Debian? openSUSE? CentOS?

Is this impossible? Or is it something no one has thought to try before?


EDIT2: My bounty has long since expired, and after 9 months, I'm assuming this is simply not possible with any Linux distro. I'll leave the question open, but I'm doubtful there will be a working solution anytime in the near future.

5 Answers 5

2

Using the Fedora 21 ISO, I just successfully tried the following:

menuentry "Fedora 21 Live M6600" --class fedora {
    insmod part_gpt
    insmod lvm
    insmod ext2
    set vg='m6600'
    set lv='F21Live'
    set root="lvm/${vg}-${lv}"
    search --no-floppy --fs-uuid --set=root --hint=${root} 95e4eec8-c1de-4802-b821-5753de990cbe
    set isofile="/Fedora-Live-Workstation-x86_64-21-5.iso"
    echo "Using ${isofile}..."
    loopback loop $isofile
    linux (loop)/isolinux/vmlinuz0 iso-scan/filename=${isofile} root=live:CDLABEL=Fedora-Live-WS-x86_64-21-5 rootfstype=auto ro rd.live.image quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 rd.auto=1
    initrd (loop)/isolinux/initrd0.img
}

rd.auto=1 will tell Linux to load all LVMs and iso-scan searches them.

2
  • The UUID in the line that starts with search is the one of the logical volume that contains the iso file, right? To get it, you have to do sudo blkid.
    – erik
    Jan 28, 2018 at 23:27
  • This could be done a lot easier, see my answer for booting Fedora and Ubuntu from LVM.
    – erik
    Jan 29, 2018 at 0:45
2

Inspired by this simple solution for Ubuntu, I used the following, which works for loading a Fedora 27 KDE iso and a Ubuntu 17.10 iso.

I just appended the following lines in the file /etc/grub.d/40_custom

menuentry "Live Fedora KDE 27" --class fedora {
  insmod part_msdos
  insmod lvm
  set iso_path="/erik/Downloads/transmission/Fedora-KDE-Live-x86_64-27/Fedora-KDE-Live-x86_64-27-1.6.iso"
  search --no-floppy --fs-uuid --set=root 6340d364-fc09-44d1-914f-b902a6394a55
  loopback loop ($root)$iso_path
  linux (loop)/isolinux/vmlinuz iso-scan/filename=${iso_path} root=live:CDLABEL=Fedora-KDE-Live-27-1-6 rootfstype=auto rd.live.image quiet
  initrd (loop)/isolinux/initrd.img
}

menuentry "Ubuntu 17.10.1" --class ubuntu {
  insmod part_msdos
  insmod lvm
  set iso_path="/erik/Downloads/transmission/ubuntu-17.10.1-desktop-amd64.iso"
  search --no-floppy --fs-uuid --set=root 6340d364-fc09-44d1-914f-b902a6394a55
  loopback loop ($root)$iso_path
  linux (loop)/casper/vmlinuz.efi  file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=${iso_path} quiet splash ---
  initrd (loop)/casper/initrd.lz
}

Explanation

  • The line that begins with set iso_path defines the path, where the iso file can be found on the logical volume. When I start my system, it lies in /home/erik/Downloads/transmission/Fedora-KDE-Live-x86_64-27/Fedora-KDE-Live-x86_64-27-1.6.iso", but /home is the mounted logical volume, so I leave this out and begin the path with /erik/Downloads/…
  • The line that begins with search has a strange alphanumerical variable (a so called UUID) at the end, that begins with 6340. I got this number from the command

    sudo blkid
    

    which gave me, along others, the following line

    /dev/mapper/fedora_pluto-home: UUID="6340d364-fc09-44d1-914f-b902a6394a55" TYPE="ext4"
    
  • Then, another important thing if you want to boot other iso files, are the lines that begin with linux and initrd. I got them by opening the iso file with file-roller (gui for extracting compressed archives) or mc (console file manager).

    • Fedora and similar: There you go to the directory /isolinux, where you will find a file called isolinux.cfg. There I found some lines beginning with label, and below them the following important lines

      kernel vmlinuz
      append initrd=initrd.img root=live:CDLABEL=Fedora-KDE-Live-27-1-6 rd.live.image quiet
      

      which you will use to fill the last two lines of my grub2 menuentry.

    • Ubuntu and similar: There you go to the directory /boot/grub, where you will find a file called grub.cfg. Here you will find some lines beginning with menuentry, and below them the following important lines

      linux   /casper/vmlinuz.efi  file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash ---
      initrd  /casper/initrd.lz
      

      which you can just copy.

0

I think that it is not possible for most distributions' official iso file.

The error you're getting :

 (initramfs) /scripts/casper-premount/20iso_scan: line 46: can't open /dev/sr0: No medium found

means that at boot, the live system you're starting is searching for a cd/dvd drive and not finding any.

Live CDs are not configured to search for their source iso on a LVM; you can maybe modify the boot scripts of the image to do it, but I don't think any current distro official .iso file does that. You can try to contact your favorite distro's devs to have that integrated maybe ?

1
  • It is possible, see my simple answer, where I boot from Fedora 27 and Ubuntu 17.10.
    – erik
    Jan 29, 2018 at 0:48
0

You could try this:

Add this at the start of the menuentry:

insmod lvm

Then, specify your LVM partition with:

set lvmpart=lvm/<lvm_group_name>-<lvm_logical_partition_name>

So your Xubuntu ISO entry would be like this:

menuentry "Xubuntu ISO" {
  insmod lvm
  set lvmpart=lvm/<lvm_group_name>-<lvm_logical_partition_name>
  set isofile="/xubuntu-12.04.1-desktop-amd64.iso"
  loopback loop $lvmpart$isofile
  linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
  initrd (loop)/casper/initrd.lz
}

Please make corrections as needed.

This should make GRUB recognize the lvm2 volume, making it possible to read the ISO file in it. However, probably the ISO will still not be found...

1
  • I tried your suggestions, but as you said, the iso still isn't found.
    – snapshoe
    May 9, 2013 at 0:15
0

Just a point on it:

The ISO when booting must mount the iso, so must know how to find it.

Grub2 can see the ISO with insmod... commands, but that makes nothing else than let Grub2 read inside the ISO, loop mount it, etc, but as soon as the Linux inside the ISO starts the LVM / LUKS / loop / etc is not there (not mounted), the boot scripts inside the ISO must know how to mount that LVM / LUKS / loop; so if that Linux is not prepared to do so, it will not be possible to boot from it.

Sample without LVM, LUKS, etc... if a normal Linux LiveCD ISO is not designed to search and mount a loop to a .iso file while booting, it will never be possible to boot into it from Grub2 (with .iso as a file).

For such cases you need a hardware CD/DVD emulator (if on real hardware), or just mount the .iso on the Virtual CD/DVD unit of a Virtual machine.

The other option, of course, is to 'edit' such ISO to incorporate at boot some scripts to search for and mount LVM / LUKS / etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .