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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-04-2017, 07:29 AM
|
#1
|
Member
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 269
Rep:
|
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.
|
|
|
12-04-2017, 09:26 AM
|
#2
|
LQ Guru
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 11,165
|
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.
|
|
|
12-04-2017, 11:04 AM
|
#3
|
Member
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224
Rep:
|
I will leave the rest of the question to others.
Quote:
Originally Posted by displace
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 11:21 AM.
|
|
|
12-05-2017, 04:57 AM
|
#4
|
Member
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 269
Original Poster
Rep:
|
Hello!
Quote:
Originally Posted by yancek
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
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
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
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
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!
|
|
|
12-05-2017, 08:21 AM
|
#5
|
Member
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224
Rep:
|
Quote:
Originally Posted by displace
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 08:23 AM.
|
|
|
12-05-2017, 12:15 PM
|
#6
|
LQ Veteran
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,712
|
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 02:11 PM.
|
|
|
12-05-2017, 02:25 PM
|
#7
|
LQ Guru
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 11,165
|
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.
|
|
|
12-05-2017, 03:46 PM
|
#8
|
Member
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 269
Original Poster
Rep:
|
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
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
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!
|
|
|
12-05-2017, 04:28 PM
|
#9
|
LQ Veteran
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,712
|
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.
|
|
|
12-06-2017, 08:40 AM
|
#10
|
Member
Registered: Jan 2009
Distribution: Fedora, Gentoo, LFS
Posts: 224
Rep:
|
Quote:
Originally Posted by yancek
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".
|
|
|
All times are GMT -5. The time now is 05:37 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|