1

Please Note: I read all posts in here, about booting ISO from partition using GRUB2 and based on that, I have tried the following, which is not worknig:

I have these partitions and I want to boot an ISO from /dev/sda5 -- should be (hda0,5) in GRUB terms.

root@myhost:/home/vyom# lsblk 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    30G  0 disk 
`-sda1   8:1    0   243M  0 part [SWAP]
`-sda2   8:2    0  11.2G  0 part /
`-sda3   8:3    0     1K  0 part 
`-sda5   8:5    0   9.3G  0 part /mypart5    <<<
`-sda6   8:6    0   9.3G  0 part /mypart6
root@myhost:/home/vyom# blkid
/dev/sda1: UUID="79813f4a-85da-4c81-a044-097922b30648" TYPE="swap" 
/dev/sda2: UUID="68923f34-385e-4740-b8af-4502aa3dd847" TYPE="ext4" 
/dev/sda5: UUID="ef7ca072-bfc9-457b-8a9e-b923fa0d3fe7" TYPE="ext4"   <<<
/dev/sda6: UUID="d8bd9333-dc41-47b3-8a42-f6c308a6f047" TYPE="ext4" 

I tried using UUID with --fs-uuid and fromiso= - didn't work:

menuentry 'UbuntuBionicVSCustom4' --class ubuntu --class gnu-linux --class gnu --class os {
   set isofile="/mypart5/ubuntu-18.04-3f8806d-test2.iso" 
   insmod ext2
   insmod loopback
   insmod iso9660
   loopback loop (hd0,5)$isofile
   search --no-floppy --fs-uuid --set=root ef7ca072-bfc9-457b-8a9e-b923fa0d3fe7
   linux (loop)/install/vmlinuz boot=install fromiso=/dev/sda5/$isofile noprompt noeject
   initrd (loop)/install/initrd.gz
}

I tried --file option to search - that too didnt work:

menuentry 'UbuntuBionicVSCustom3' --class ubuntu --class gnu-linux --class gnu --class os {
   set isofile="/mypart5/versa-flexvnf-3f8806d-21.2.1-B-S.iso"
   insmod ext2
   insmod part_msdos
   insmod lvm
   insmod loopback
   insmod iso9660
   search --file --no-floppy --set=root "${isofile}"
   loopback loop "(${root})${isofile}"
   linux (loop)/install/vmlinuz boot=install findiso="${isofile}" noprompt noeject
   initrd (loop)/install/initrd.gz
}

The ISO file is actually at: /mypart5/ubuntu-18.04-3f8806d-test2.iso

So, should I do:

   set isofile="/mypart5/ubuntu-18.04-3f8806d-test2.iso"

OR, just:

   set isofile="ubuntu-18.04-3f8806d-test2.iso"

So that, next I can do:

   loopback loop (hd0,5)$isofile

also, I am confused with the kernel command line options, should I use:

     fromiso=/dev/sda5/$isofile

OR

     findiso="${isofile}"

OR

     iso-scan/filename=${isofile}

OR

     isoloop=/${isofile}

I am not able to get GRUB to actually pick the file from the partition /dev/sda5 mounted on /mypart5. I get "error: no such device" or unknown filesystem . Please help me what I am missing here!

Ani
  • 39
  • More info on booting ISO files. https://askubuntu.com/questions/1269462/bios-uefi-template-image-for-booting-iso-files and https://askubuntu.com/questions/1251729/20-04-booting-iso-from-grub-menu/1251782#1251782 – C.S.Cameron Feb 25 '21 at 14:32
  • 1
    Try adding a slash: set isofile="/ubuntu-18.04-3f8806d-test2.iso" – ubfan1 Feb 25 '21 at 16:50
  • More examples: https://help.ubuntu.com/community/Grub2/ISOBoot/Examples If you have created a custom ISO, best to test path & boot stanza with a known working ISO. Then you know detals are correct and whether issue is path, boot stanza, or ISO itself. – oldfred Feb 25 '21 at 20:44

1 Answers1

4

Try this:

menuentry 'UbuntuBionicVSCustom3' {
  set root='hd0,5'
  set isofile=/ubuntu-18.04-3f8806d-test2.iso
  loopback loop $isofile
  linux (loop)/install/vmlinuz boot=install iso-scan/filename="${isofile}" noprompt noeject
  initrd (loop)/install/initrd.gz
}
  • 1
    It looks like the OP is using msdos partition tables, not gpt. The ISO should boot fine just using (hd0,5), no gpt, msdos required. – C.S.Cameron Feb 25 '21 at 14:20
  • @C.S.Cameron Indeed, I just wanted to highlight the diference between the two partition tables, for future readers. – schrodingerscatcuriosity Feb 25 '21 at 14:24
  • 1
    Adding gpt or msdos just makes things more complicated and is not required. – C.S.Cameron Feb 25 '21 at 14:27
  • Oh, ok, what happens is that some time ago I couldn't boot an ISO if gpt was not specified, but I may be misremembering. I'll update the answer removing that part. – schrodingerscatcuriosity Feb 25 '21 at 14:32
  • @schrodigerscatcuriosity you probably meant just /iso-file when you wrote /path/to/iso. I had to just remove the mount directory and use like: set isofile="/the-iso-file and loopback loop (hd0,5)$isofile. Now that ISO boots, its getting stuck at loading CD-ROM! (separate issue though). Thanks. Can I edit your answer to what worked for me ? – Ani Feb 26 '21 at 08:05
  • 1
    @vyom when you set root='hd0,5', you don't need then to add it to the loopback. Every path in the configuration will assume the root as 'hd0,5', meaning / is hd0,5. /path/to/the/iso represents any path in your 5th partition where you put the image. For example, you can place it under a directory called isos. The path then would be /isos/$isofile (translated = (hd0,5)/isos/theiso.iso). – schrodingerscatcuriosity Feb 26 '21 at 08:16
  • @vyom Updated the answer according to your needs I hope, let me know of any problem. – schrodingerscatcuriosity Feb 26 '21 at 08:20
  • @vyom I said -"Every path in the configuration will assume the root as 'hd0,5'"-, but it is some paths, depending on the config keyword. – schrodingerscatcuriosity Feb 26 '21 at 08:26