LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-04-2017, 06:29 AM   #1
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Rep: Reputation: 25
Multiboot USB with ISO images - BIOS & UEFI - how?


Hey.

I'm kinda uncertain what to use here. Thing is I have a keyring or rather a USB-ring with many USB keys with each having a single operating system on it. Debian, Ubuntu variants, Mint, Arch, SystemRescueUSB, Windows, etc. The keyring is getting rather big so thought I'd use some means to boot several operating systems from a single stick by grouping together similar ISO images. Usually I would simply dd the iso file onto the USB stick, but with multiple images I'll have to make a filesystem instead and store the individual iso files on it. The problem is there can only be one bootloader per USB stick, so obviously this means I'll have to use a 3rd party bootloader to choose an ISO at boot.

I noticed that lots of the live Linux ISO's will automatically choose an appropriate way to boot i.e. if the hardware starts with legacy (BIOS/MBR), the system will also boot in legacy mode. Likewise, if the hardware is booted in UEFI/GPT mode, the OS will boot in UEFI mode as well. So this needs to carry through from the bootloader to the system on the ISO image.


What's the recommended thing to use here? Syslinux? GRUB2? I'd love to use rEFInd, but it's UEFI-only.
 
Old 12-04-2017, 08:26 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
You would install Grub2 initially to the usb stick, then copy the various iso files to the stick on the same or a different partition you previously created and then you would manually create a grub.cfg file with boot entries to boot the various Linux systems. There are numerous tutorials on booting an iso directly with Grub2 so you should not have any problem finding examples. I seriously doubt that you will be able to boot a windows iso directly nor would it be reasonable to expect to do so. Some example entries at the link below. If you have a specific distro you want, just do an online search for that specific distro. Most newer Linux systems will boot an iso directly from Grub2 but not all will.

https://help.ubuntu.com/community/Gr...OBoot/Examples

A sample method to install Grub2 to the flash drive below IF the flash drive is sdc, you are booting from another Linux system and have created the flash/boot directory mount points in your installed /mnt directory and mounted it. If your system doesn't use sudo, just obviously login as root user. It should work without the "--forc --no-floppy" options but if it doesn't, use them.

Code:
sudo grub-install --force --no-floppy --boot-directory=/mnt/flash/boot /dev/sdc
My experience is that a Linux system will install EFI if it is set to boot EFI in the boot options or BIOS and will install Legacy if it is set to CSM/Legacy. I've used the same Linux iso file on a flash drive booted this way to install EFI and Legacy. When I look at boot options/BIOS on my machine with a bootable flash drive plugged in it shows up twice, one with EFI as an option and one with Legacy/CSM as an option with the brand name of the flash. Don't have any idea if this will work on all systems.
 
Old 12-04-2017, 10:04 AM   #3
plasmonics
Member
 
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224

Rep: Reputation: 69
I will leave the rest of the question to others.
Quote:
Originally Posted by displace View Post
The problem is there can only be one bootloader per USB stick, so obviously this means I'll have to use a 3rd party bootloader to choose an ISO at boot.
A usb stick can contain more than one boot loader. There are a number of possibilities.

You can partition the usb with a GPT label. Then create two 100 MiB partitions, one of type code EF00 and the other of type code EF02. The first one is the ESP and the second one is the bios compatibility layer. You then have the option of installing grub-efi on the ESP and either grub-i386 or syslinux on the ef02 partition.

When you boot the stick on legacy hardware, the bios looks for a boot loader in the ef02 partition. Ordinarily, bios hardware cannot see gpt-labelled disks. The bios-compatibility layer makes the disk look like an MBR/MSDOS-labelled disk and allows it to see all the partitions on the disk.

When you boot the stick on UEFI hardware with CSM enabled, the firmware looks for a boot loader in two places, ef00 and ef02. That is why you see two entries on the screen. If you had set up the stick with an MSDOS label, you would only be able to boot it in CSM mode.

I have a lexar usb 3.0 stick set up this way.

Although I have not yet tried it, I believe you can even put a third boot loader on it. Syslinux is supposed to be able to load grub4dos. The latest syslinux supposedly can also boot in uefi mode. You should be able to put syslinux-efi on the ESP side by side with grub-efi, giving a total of four boot loaders.

Last edited by plasmonics; 12-04-2017 at 10:21 AM.
 
Old 12-05-2017, 03:57 AM   #4
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Original Poster
Rep: Reputation: 25
Hello!

Quote:
Originally Posted by yancek View Post
You would install Grub2 initially to the usb stick, then copy the various iso files to the stick on the same or a different partition you previously created and then you would manually create a grub.cfg file with boot entries to boot the various Linux systems. There are numerous tutorials on booting an iso directly with Grub2 so you should not have any problem finding examples.
Yes, I had imagined it would be set up this way. Alrighty then, I'll go along with GRUB2 and dump the other options for now.

Quote:
Originally Posted by yancek View Post
I seriously doubt that you will be able to boot a windows iso directly nor would it be reasonable to expect to do so.
Oh, how so? I assumed that if a CD/DVD ISO image is bootable then it can be booted from GRUB2.

Quote:
Originally Posted by yancek View Post
My experience is that a Linux system will install EFI if it is set to boot EFI in the boot options or BIOS and will install Legacy if it is set to CSM/Legacy. I've used the same Linux iso file on a flash drive booted this way to install EFI and Legacy. When I look at boot options/BIOS on my machine with a bootable flash drive plugged in it shows up twice, one with EFI as an option and one with Legacy/CSM as an option with the brand name of the flash. Don't have any idea if this will work on all systems.
Wait, what exact logic detects and decides which mode an OS will boot into - where is this logic located? Is it in the UEFI firmware, is it the bootloader or the kernel itself? Are there separate kernels for legacy and uefi?


Quote:
Originally Posted by plasmonics View Post
You can partition the usb with a GPT label. Then create two 100 MiB partitions, one of type code EF00 and the other of type code EF02. The first one is the ESP and the second one is the bios compatibility layer. You then have the option of installing grub-efi on the ESP and either grub-i386 or syslinux on the ef02 partition.
Yes, with the UEFI there can be many bootloaders provided that the firmware can switch between them, but in legacy mode afaik there can be only a single working one - it's the one installed on the MBR, and you can use this one to chainload other bootloaders. I've setup my Veracrypt bootloader to chainload GRUB2 on an empty 1MB partition, and that was a pain to install because GRUB2 refuses to install on a partition without a filesystem. Had to make a fake btrfs header on it so grub would install.

Quote:
Originally Posted by plasmonics View Post
When you boot the stick on legacy hardware, the bios looks for a boot loader in the ef02 partition. Ordinarily, bios hardware cannot see gpt-labelled disks. The bios-compatibility layer makes the disk look like an MBR/MSDOS-labelled disk and allows it to see all the partitions on the disk.

When you boot the stick on UEFI hardware with CSM enabled, the firmware looks for a boot loader in two places, ef00 and ef02. That is why you see two entries on the screen. If you had set up the stick with an MSDOS label, you would only be able to boot it in CSM mode.
I have some experience setting up legacy GRUB2, but I'll need to do some reading on UEFI. So basically if I want to make a multi-mode boot stick (uefi + legacy) then I will need to use two bootloaders - one UEFI and the other legacy? Is there any chance to have a single bootloader that works for both modes (just asking)?


Best regards!
 
Old 12-05-2017, 07:21 AM   #5
plasmonics
Member
 
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224

Rep: Reputation: 69
Quote:
Originally Posted by displace View Post
I have some experience setting up legacy GRUB2, but I'll need to do some reading on UEFI. So basically if I want to make a multi-mode boot stick (uefi + legacy) then I will need to use two bootloaders - one UEFI and the other legacy? Is there any chance to have a single bootloader that works for both modes (just asking)?
The two firmwares, UEFI and BIOS, search for boot loaders differently, so I don't see how a single boot loader can be used for both modes.

If you loop mount a hybrid iso made for dual use, e.g., fedora, arch, ubunto, etc., you will see two boot loaders. isolinux is the legacy loader and grub-efi the uefi boot loader. They use separate cfg files. When you boot the iso from legacy hardware, it sees just isolinux. When you boot from UEFI hardwarte with CSM disabled, it sees just grub-efi. With CSM enabled, it sees both. When you use dd to burn the iso to a usb stick, all of that infrastructure is inherited by the usb, provided that the iso is hybrid.

The usb stick will need two boot loaders. If you use syslinux for legacy and grub-efi for uefi, you will need to make separate syslinux.cfg and grub.cfg menu files.

if you use grub for both modes, you have the advantage of using a single grub.cfg, but it must contain if....elif...fi semantics. This is because the two modes use different loadable modules. The loadable modules that are common to both can be placed outside of the if clause.

Last edited by plasmonics; 12-05-2017 at 07:23 AM.
 
Old 12-05-2017, 11:15 AM   #6
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
Quote:
Wait, what exact logic detects and decides which mode an OS will boot into - where is this logic located? Is it in the UEFI firmware, is it the bootloader or the kernel itself? Are there separate kernels for legacy and uefi?
The firmware determines to boot in efi or legacy mode depending on the bootloader available and the settings in the firmware. If the firmware is set to boot in efi mode only, it looks for the boot loader on the efi partition. Some efi firmware requires the bootloader on the efi partition to be named as efi/boot/bootx64.efi if it is 64 bit firmware or efi/boot/bootx32.efi if it is 32bit firmware, not to be confused with a 64bit or 32bit distro. If the firmware is set for legacy booting the firmware will only look for the bootloader in the mbr. If set for both legacy and efi, then the firmware will look for bootloaders in both the efi partition and the MBR. Even through you can create a kernel stub that efi firmware can boot, the kernel doesn't determine boot mode. One can create a drive that will boot the same disto installation in either efi or legacy mode, thus making it portable between old legacy hardware and new efi hardware.

I have used yumi, a window program able to create a multiboot efi/legacy usb with its YUMI-UEFI-0.0.0.5.exe
https://www.pendrivelinux.com/yumi-m...t-usb-creator/

I'm not too familiar with this one so don't know how well it works
http://multibootusb.org/

Last edited by colorpurple21859; 12-05-2017 at 01:11 PM.
 
Old 12-05-2017, 01:25 PM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,502

Rep: Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489Reputation: 2489
Quote:
Oh, how so? I assumed that if a CD/DVD ISO image is bootable then it can be booted from GRUB2.
The iso itself needs to be bootable in that manner which usually means having some specific software for that purpose in the iso. There are still a number of Linux distributions which cannot be booted directly from the iso and when Grub first had this capability there were very few which would directly boot an iso. I don't know if there is any windows software which can boot an iso directly from a hard drive or flash drive but I would not expect Grub or any Linux bootloader to do so and can't imagine why any Linux developer would waste their time with it. Additionally, the fact that about 95% of windows home computer users have pre-installed systems, there isn't much incentive for microsoft to do that.

You can extract the windows iso and copy the files to a flash drive partition and boot it that way with either Legacy Grub or Grub2. Neither Grub Legacy or Grub2 directly boots windows but rather chainloads by basically pointing to the location of the windows boot files and its bootloader takes over. Booting an extracted windows from Grub2 is explained in detail at the link below. You need a separate ntfs partition to do that but that's all explained at the site.

http://onetransistor.blogspot.ch/201...om-ubuntu.html

I tested some bootable flash drives I have and only the Sandisk work the way I described in the earlier post, with a separate entry for UEFI for the flash drive and another for Legacy so I expect it is as explained by other members above, something in the firmware.
 
Old 12-05-2017, 02:46 PM   #8
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Original Poster
Rep: Reputation: 25
Yeah, I get it now. Looking at it from technical perspective, it makes sense that the firmware would look for a boot loader at different locations depending on the mode used (CMS or UEFI).

Quote:
Originally Posted by plasmonics View Post
if you use grub for both modes, you have the advantage of using a single grub.cfg, but it must contain if....elif...fi semantics. This is because the two modes use different loadable modules. The loadable modules that are common to both can be placed outside of the if clause.
Excellent! This was one of the questions I was about to ask here. I'll see, if I can setup GRUB2 this way because it seems more convenient to have a single config. Time for some learning and experimentation.

Quote:
Originally Posted by yancek View Post
You can extract the windows iso and copy the files to a flash drive partition and boot it that way with either Legacy Grub or Grub2. Neither Grub Legacy or Grub2 directly boots windows but rather chainloads by basically pointing to the location of the windows boot files and its bootloader takes over. Booting an extracted windows from Grub2 is explained in detail at the link below. You need a separate ntfs partition to do that but that's all explained at the site.
Hmm, interesting. I'll give it a shot. I was under impression that if an ISO is bootable by itself that GRUB2 could simply mount the image, chainload its bootloader and make it boot. Although extracting doesn't seem too much different, I'll give it a shot and see how it turns out.


Thanks for all the answers!
 
Old 12-05-2017, 03:28 PM   #9
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,346

Rep: Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589Reputation: 1589
Quote:
I'll see, if I can setup GRUB2 this way because it seems more convenient to have a single config.
It is possible with Debian based systems as both efi and legacy uses /boot/grub/grub.cfg for booting. The problem is that Debian based systems only allow either grub-i386pc(legacy mode) or grub-x86efi installed one at a time not both. Slackware also uses /boot/grub/grub.cfg for both and also has both booting modes of grub installed, not sure about other distros like arch.
 
Old 12-06-2017, 07:40 AM   #10
plasmonics
Member
 
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224

Rep: Reputation: 69
Quote:
Originally Posted by yancek View Post
I tested some bootable flash drives I have and only the Sandisk work the way I described in the earlier post, with a separate entry for UEFI for the flash drive and another for Legacy so I expect it is as explained by other members above, something in the firmware.
So far, I have had good results with a Corsair Voyager, Corsair Slider, and Lexar S75.

Some vendors ship the drive with a hardware-encoded partition table. I used to have one of those. Real headache to use.
Since sector 0 is write protected, you cannot install a boot loader.

Some vendors ship the drive with a firmware bug. The flip bit (bit 7 of the first byte) is not set. If the flip bit is set, when you plug the drive into Windows file manager, you should see the word "removable".
 
Old 12-07-2017, 11:04 AM   #11
Howling-Wolf
LQ Newbie
 
Registered: Oct 2016
Posts: 5

Rep: Reputation: Disabled
Smile

Also you can take a look at http://www.easy2boot.com/ HTH
 
  


Reply

Tags
iso, multiboot, uefi, usb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
(Patience) Can't get UEFI?BIOS to multi?boot USB on 2G/32G tablet GentleThotSeaMonkey Linux - Newbie 18 11-21-2017 12:47 PM
Multiboot Iso / USB /dvd? blizz1987 Linux - Software 1 08-02-2015 11:31 AM
Clonezilla and Multiboot Iso Mount USB Drive jghake Linux - Newbie 11 02-02-2014 04:17 PM
Booting btrfs usb-stick via uefi-bios. ssenuta Linux - General 1 06-29-2013 09:59 PM
Help Creating UEFI A MENU For My Bootable (BIOS/UEFI) CDROM ssenuta Linux - Hardware 0 08-27-2012 09:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration