Page 1 of 1

EFI, Grub2 and Windows multi boot

Posted: 15 Dec 2015, 04:08
by Ed_P
If you run Windows and want to multi-boot Porteus or other ISOs take a look at Grub2Win. And the /grub2/grub.cfg file can be easily manually edited to add Porteus ISOs. :good:

Code: Select all

# start-grub2win-user-section   ********************************************************
#
menuentry "Porteus LXQT ISO" --class slackware   --class icon-porteus  {
     echo Boot disk address is  $root
     echo Prefix is             $prefix
     echo The boot mode is      $grub2win_bootmode

     set iso=/ISOs/Porteus-LXQT-v3.1-x86_64-nu.iso

     search -f $iso --set=root
     echo ISO root is           $root
     echo ISO is                $iso
     if [ -f (hd1,1)/USB_INSTALLATION.txt ]; then
         set linux_drv=/mnt/sdb1/porteus3.1
     else
         set linux_drv=/mnt/sda5/porteus3.1
     fi
     echo Porteus extramods     $linux_drv
     echo
     loopback loop $iso
     sleep -v -i 7
     echo "Loading Linux"
     linux (loop)/boot/syslinux/vmlinuz from=$iso extramod="$linux_drv/Modules;$linux_drv/modsavedat" volume=33 reboot=cold
     echo "Loading initrd"
     initrd (loop)/boot/syslinux/initrd.xz
}

menuentry "Porteus Nemesis ISO" --class slackware   --class icon-linux  {
     echo Boot disk address is  $root
     echo Prefix is             $prefix
     echo The boot mode is      $grub2win_bootmode

     set iso=/ISOs/porteus-nemesis-v3.3-x86_64.iso

     search -f $iso --set=root
     echo ISO root is           $root
     echo ISO is                $iso
     echo
     loopback loop $iso
     sleep -v -i 7
     echo "Loading Linux"
     linux (loop)/boot/syslinux/vmlinuz from=$iso volume=33 reboot=cold
     echo "Loading initrd"
     initrd (loop)/boot/syslinux/initrd.xz
}

menuentry   'Reboot' --class slackware --class icon-reboot  {
     reboot
}
#
# end-grub2win-user-section     ********************************************************
Grub2Win works with both BIOS and UEFI systems.

To boot ISOs on the EFI Porteus USB drive copy the grub2 folder to the root and the /EFI/grub2win folder to the USB's /EFI/ folder and add this to the refind.conf file:

Code: Select all

menuentry Grub2 {
	loader /EFI/grub2win/grub2win.boot.efi
	icon /EFI/BOOT/icons/os_linux.png
}
:)

Re: EFI, Grub2 and Windows multi boot

Posted: 15 Dec 2015, 16:39
by brokenman
I was lucky with my new machine (dell) in that I could simply copy the refind bootloader onto the EFI partition. Then in windows I opened a command prompt and changed the default bcd.

Code: Select all

bcdedit /set {bootmgr} path \EFI\refind\refind_x64.efi
Now when I start the machine it shows me the refind bootloader. In this way I can update windows or the linux kernel with ease. Also (on a side note) windows 10 uses UTC for the system clock. win/win

Re: EFI, Grub2 and Windows multi boot

Posted: 15 Dec 2015, 18:57
by Ed_P
brokenman wrote:Then in windows I opened a command prompt and changed the default bcd.
I like that approach. :good: Thanks. :friends: But it won't support booting ISOs, that's why I had to add grub2 to my system. Should be able to do that also with your config.

Re: EFI, Grub2 and Windows multi boot

Posted: 15 Dec 2015, 20:35
by brokenman
But it won't support booting ISOs
Are you sure? refind is just a bootloader that loads Porteus. Just edit the refind.conf file and it should support booting any ISO with the from= cheatcode. You could even just use bcdedit to load the grub_x64.efi loader if you don't want to use refind.

Re: EFI, Grub2 and Windows multi boot

Posted: 16 Dec 2015, 01:29
by Ed_P
brokenman wrote:
But it won't support booting ISOs
Are you sure?
Yes. According to Rod (Smith) "it would require the development of an EFI loopback driver -- that is, a driver that makes files look like disks. AFAIK, no such driver yet exists. I've been wanting to write such a driver for a while, but I haven't gotten around to it." This was as of last month.
You could even just use bcdedit to load the grub_x64.efi loader if you don't want to use refind.
Interesting. Basically that is what Grub2Win does on UEFI systems. On my Porteus USB drive there is no BCD so I copied the Grub2Win files over and added the menu item to rEFInd for it. (I also added a menu item to Porteus.cfg for grub4dos on BIOS systems. :) )

Re: EFI, Grub2 and Windows multi boot

Posted: 16 Dec 2015, 02:47
by brokenman
I just booted from an ISO through refind on my UEFI system. It definitely works. I am posting from it now.

Code: Select all

guest@porteus:~$ cat /proc/cmdline 
quiet \EFI\porteus-v3.1\vmlinuz from=/dev/sda8/Porteus-MATE-v3.1-x86_64.iso initrd=EFI\porteus-v3.1\initrd.xz
As I said, refind is just a loader. Once the kernel and initrd are loaded they can boot from anywhere, even over a network.
Interesting. Basically that is what Grub2Win does on UEFI systems.
Yes. My point is that (if you are lucky) an EFI system can pass directly to any .efi loader. No need to chainload two .efi files. On my last system I couldn`t because it only loaded from the fallback EFI path which meant I had to overwrite it. You can try it by entering the line (above post) in a windows (administrator) command prompt. Sure made life easier for me. Manufacturers are starting to ease up a little.

Re: EFI, Grub2 and Windows multi boot

Posted: 16 Dec 2015, 03:27
by Ed_P
brokenman wrote:I just booted from an ISO through refind on my UEFI system. It definitely works. I am posting from it now.
:shock: Can you post your rEFInd menuentry that you're using to do it? Is this with a newer version of rEFInd? Rod Smith, the author of rEFInd, said it needed a driver.
As I said, refind is just a loader. Once the kernel and initrd are loaded they can boot from anywhere, even over a network.
But kernel and initrd are inside the ISO and rEFInd doesn't/didn't have a loopback command.

Re: EFI, Grub2 and Windows multi boot

Posted: 16 Dec 2015, 03:51
by brokenman

Code: Select all

menuentry "Porteus Nemesis" {
	icon EFI/refind/icons/os_arch.png
	loader EFI/nemesis-v3.4/vmlinuz
	initrd EFI/nemesis-v3.4/initrd.xz
	options "from=/dev/sda8/nemesis-v3.4.iso"
}
I am using version 0.10.1. I don't think it's changed for a while.
Rod Smith, the author of rEFInd, said it needed a driver.
You only need the driver for the filesystem that the iso file sits on. If that filesystem is made available and your kernel and initrd loads then it is business as usual. The kernel is told where the ISO file is, initrd loads and starts the boot process. Obviously the kernel and initrd are outide of the iso as you can see in the refind.conf entry above.
But kernel and initrd are inside the ISO and rEFInd doesn't/didn't have a loopback command.
Well, look closer at the post I made above again. The code box with the (cat /proc/cmdline) line containing initrd and vmlinuz. They're outside the ISO. This allows me to load whatever ISO file i want, and all from the same (latest) kernel.

As a bonus for me, this laptop autodetects if the boot device is EFI or standard BIOS and boots from either one. :good:
Manufacturers are starting to comply with what people need/want. Secure boot is not stopping anyone.

Re: EFI, Grub2 and Windows multi boot

Posted: 16 Dec 2015, 05:49
by Ed_P
brokenman wrote:Obviously the kernel and initrd are outide of the iso as you can see in the refind.conf entry above.
Exactly, which to me means I need a folder of kernels and initrds for each ISO I try to boot. Maybe all the Porteus ISOs can do that but I'm not sure that works for all ISOs especially the Windows ones.
Well, look closer at the post I made above again. The code box with the (cat /proc/cmdline) line containing initrd and vmlinuz. They're outside the ISO. This allows me to load whatever ISO file i want, and all from the same (latest) kernel.
The outside part I understand. The same kernel/initrd combo working for all ISOs is the part I'm struggling with.
My world:

Code: Select all

C:\Users\Ed>dir F:\ISOs\*.iso
 Volume in drive F is SanDisk
 Volume Serial Number is 49AA-0A17

 Directory of F:\ISOs

03/27/2013  02:39 AM       408,723,456 systemrescuecd-x86-3.5.0.iso
02/04/2013  01:53 PM       312,475,648 pmagic_2013_01_29.iso
06/08/2011  12:59 PM       149,303,296 REPAIR_DISC_WINDOWS_7_32_BIT.iso
06/07/2012  03:40 PM       191,782,912 REPAIR_DISC_WINDOWS_7_64_BIT.iso
01/31/2015  07:56 AM       190,763,008 Porteus-RazorQT-v3.0.1-i486-nu.iso
07/26/2011  01:24 PM       121,110,528 Acronis.iso
01/06/2013  07:33 PM        42,565,632 Acer-725-Recovery.iso
03/11/2011  11:54 PM         7,716,864 rc.iso
04/07/2011  10:27 PM           305,152 windiag.iso
               9 File(s)  1,424,746,496 bytes
               0 Dir(s)   6,007,533,568 bytes free

C:\Users\Ed>dir D:\ISOs\*.iso
 Volume in drive D is Data
 Volume Serial Number is 6B8B-F780

 Directory of D:\ISOs

04/22/2014  02:14 PM       661,499,904 pebuilder.iso
07/10/2015  08:03 PM        36,700,160 Porteus-Kiosk-3.4.0-i486.iso
02/02/2015  11:46 PM       194,439,168 Porteus-LXQT-v3.1-x86_64-nu.iso
12/14/2014  04:55 PM       195,305,472 Porteus-LXQT-v3.1-x86_64.iso
11/24/2015  02:23 AM       207,640,576 porteus-nemesis-v3.3-x86_64.iso
01/31/2015  07:56 AM       190,763,008 Porteus-RazorQT-v3.0.1-i486-nu.iso
09/15/2014  06:19 PM       224,536,576 Porteus-RazorQT-v3.0.1-i486.iso
01/30/2015  11:12 PM       198,993,920 Porteus-RazorQT-v3.0.1-x86_64-nu.iso
08/05/2014  09:08 AM       233,545,728 Porteus-RazorQT-v3.0.1-x86_64.iso
08/29/2015  09:36 PM            34,816 Recovery.iso
06/07/2012  03:40 PM       191,782,912 REPAIR_DISC_WINDOWS_7_64_BIT.iso
02/27/2013  06:23 PM       237,113,344 REPAIR_DISC_WINDOWS_8_64_BIT.iso
              12 File(s)  2,572,355,584 bytes
               0 Dir(s)  36,568,600,576 bytes free

And I have others. And it may expand depending on what gifts are exchanged at Christmas. Granted I am no Linux expert, and I have little/no knowledge of what is inside a kernel or initrd so maybe you're right, a common set of files may boot more than one ISO. In my Porteus 3.1 ISO I am using the kernel from 3.0.1..

I assume you have a handy script for extracting these two files from an ISO? :)

Re: EFI, Grub2 and Windows multi boot

Posted: 16 Dec 2015, 21:28
by brokenman
I assume you have a handy script for extracting these two files from an ISO?
No. I do it manually.

Code: Select all

mloop /path/to/myiso.iso
cp -a /mnt/loop/boot/syslinux/{vmlinuz,initrd.xz} /tmp

Re: EFI, Grub2 and Windows multi boot

Posted: 17 Dec 2015, 05:30
by Ed_P
brokenman wrote:

Code: Select all

mloop /path/to/myiso.iso
cp -a /mnt/loop/boot/syslinux/{vmlinuz,initrd.xz} /tmp
Really!! That's it!! :oops:

<sigh> Thank you brokenman. :)