You are not logged in.

#1 2015-03-16 09:51:29

hifi25nl
Member
Registered: 2011-05-07
Posts: 263

An USB stick that can boot both in UEFI and BIOS mode

Is this possible? An USB stick that can boot both in UEFI and BIOS mode automatically?
I have already made an USB stick with archlinux (not a Live USB) with Syslinux installed on MBR and the esp partition for uefi.

The stick is working fine in different computers with BIOS systems.
For what I understand from the wiki and the documentation there is not a reason against this:
1) syslinux "BIOS" installed to MBR
2) syslinux "UEFI" installed  to vfat special esp partition.
In this case I would have a /boot folder in the primary ext4 partition and inside it a /boot/syslinux/EFI folder where the esp partition is mounted.
If the USB stick is connected to a BIOS computer it will use the MBR syslinux, oherwise it will use the esp partition.

But how to do 2)  in practice?
I was hoping that a "blind" installation of syslinux uefi was possible from a BIOS computer...

Last edited by hifi25nl (2015-03-16 09:53:26)

Offline

#2 2015-03-16 20:58:39

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,778
Website

Re: An USB stick that can boot both in UEFI and BIOS mode

This is certainly possible as I have done it myself big_smile

I didn't use syslinux though and I am uncertain as to it's usage.

In my case I used a GUID partition table (GPT) with a 512MiB FAT32 EFI system partition and a BIOS boot partition (type "EF02" in gdisk) and installed gummiboot for EFI-mode booting and GRUB for non-EFI booting.

To install GRUB for non-EFI booting, use this command:

# grub-install --target=i386-pc --recheck /dev/sd<x>

Replace <x> with the letter assigned to your USB stick.

I think this would also work with an MBR-type disk, but I've never tried that.


Jin, Jîyan, Azadî

Offline

#3 2015-03-16 21:44:59

fjvinal
Member
From: Madrid
Registered: 2012-06-23
Posts: 45

Re: An USB stick that can boot both in UEFI and BIOS mode

I use syslinux for BIOS/EFI boot with the following configuration:
- A separate boot partition with FAT32 format, mounted in /boot
- A "syslinux" folder for BIOS boot (installed with "syslinux-install_update -i -a -m")
- A "EFI/boot" folder for EFI boot, installed manually:
   - Copy all *.c32 objects from "/usr/lib/syslinux/efi64/"
   - Copy "syslinux.efi" to "bootx64.efi"
- Edit "syslinux.cfg" in both folders (changing ../ to ../../ for relative paths in the second case)

That is all.

Offline

#4 2015-03-16 21:52:48

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: An USB stick that can boot both in UEFI and BIOS mode

@fjvinal: Is it needed to have two syslinux.cfg files? Just one as /boot/syslinux/syslinux.cfg should be enough, the EFI loader in /boot/EFI/boot should be able to read it.

Offline

#5 2015-03-16 22:52:45

hifi25nl
Member
Registered: 2011-05-07
Posts: 263

Re: An USB stick that can boot both in UEFI and BIOS mode

@fjvinal: I am not sure if it is the same I have made myself.
The USB stick is /dev/sdd, the vfat partition is /dev/sdd1, the ext4 partition is /dev/sdd2

1) Following the wiki I have made the partitions with parted:

mklabel gpt
mkpart ESP fat32 1M 513M
mkpart primary ext4 513M 100%

2) I have formatted the partitions:

mkfs.vfat -F32 /dev/sdd1
mkfs.ext4 /dev/sdd2

3) In chroot I have installed syslinux "BIOS" to MBR:

syslinux-install_update -i -a -m

This way I have now a /boot directory in ext4 partition (/dev/sdd2)

4) I have mounted /dev/sdd1 (the vfat partion) to /boot (in /dev/sdd2)

mkdir -p /boot/EFI
mount -t vfat /dev/sdd1 /boot/EFI
mkdir -p /boot/EFI/syslinux
cp /usr/lib/syslinux/efi64/* /boot/EFI/syslinux/

Now I have both /boot/syslinux and /boot/EFI/syslinux or should be /boot/EFI/boot/syslinux?
--> Here you are saying that I must copy "syslinux.efi" to "bootx64.efi"

5) I have copied the /boot/syslinux/syslinux.cfg to /boot/EFI/syslinux/syslinux.cfg changing ../ to ../../

Is this right?
If I understand right the command reported in the wiki (impossible to use in BIOS systems)
"efibootmgr -c -d /dev/sdX -p Y -l /EFI/syslinux/syslinux.efi -L "Syslinux"
is usless here since syslinux.efi is already copied to bootx64.efi and syslinux.cfg is already modified

Last edited by hifi25nl (2015-03-16 23:14:18)

Offline

#6 2015-03-16 23:18:29

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: An USB stick that can boot both in UEFI and BIOS mode

The vfat partition should be mounted to /boot, not to /boot/EFI. And you should run "syslinux-install_update -i -a -m" *after* mounting it. The idea is that both BIOS and UEFI loaders (as well as the kernel and initramfs) are on the vfat partition. Whereas now you have the BIOS one on the ext4 partition. The /boot dir on the ext4 partition should be empty. The contents of /usr/lib/syslinux/efi64 then goes to /boot/EFI, not to /boot/EFI/syslinux. And once copied, rename syslinux.efi to bootx64.efi

Edit: The contents of /usr/lib/syslinux/efi64 go to /boot/EFI/boot instead of what I wrote above. This is because EFI/Boot/bootx64.efi is considered the default loader. There can be differently named loaders in other places, but this then requires extra configuration. But if EFI/Boot/bootx64.efi is there, it'll be loaded without any special configuration.

Last edited by Gusar (2015-03-18 12:39:38)

Offline

#7 2015-03-17 13:15:03

hifi25nl
Member
Registered: 2011-05-07
Posts: 263

Re: An USB stick that can boot both in UEFI and BIOS mode

Ok, now I have /boot empty if I mount only ext4 partiion (/dev/sdd2).
If I mount vfat /dev/sdd1 I have /boot/syslinux and /boot/EFI (not /boot/EFI/syslinux)
I have installed syslinux with syslinux-install_update -i -a -m
and re-made the initrd image

However the USB stick is not starting in a BIOS computer. If I select an option in syslinux menu I will return immediatly to the menu.
If I edit the line with tab excluding initrd I have a kernel panic with unknown_block(0,0)
So something is wrong...

My fstab:

UUID=64C2-784D     /boot    vfat    defaults    0   2 
UUID=4560c944-3afe-49e2-9a91-4249f48eb296	/    ext4   defaults,noatime,nodiratime  0 1

In /boot/syslinux/syslinux.cfg:

LABEL arch
    MENU LABEL Arch Linux
    LINUX ../vmlinuz-linux
    APPEND root=UUID=4560c944-3afe-49e2-9a91-4249f48eb296 rw quiet
    INITRD ../intel-ucode.img,../initramfs-linux.img

Result of fdisk -l:

Disk /dev/sdd: 14.6 GiB, 15693664256 bytes, 30651688 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 30CB7FC5-CB75-4960-BD76-43D757B36302

Device       Start      End  Sectors  Size Type
/dev/sdd1     2048  1001471   999424  488M EFI System
/dev/sdd2  1001472 30650367 29648896 14.1G Linux filesystem

and finally blkid:

/dev/sdd1: UUID="64C2-784D" TYPE="vfat" PARTUUID="3a55272b-2938-4ad9-ba95-440435d17313"
/dev/sdd2: LABEL="audiolinux_15315" UUID="4560c944-3afe-49e2-9a91-4249f48eb296" TYPE="ext4" PARTUUID="fd980d81-e1f2-4d0f-96d1-603996645e4b"

Offline

#8 2015-03-17 14:31:19

hifi25nl
Member
Registered: 2011-05-07
Posts: 263

Re: An USB stick that can boot both in UEFI and BIOS mode

MMM..I forgot to renstall intel-ucode. Now boot is OK in BIOS system.

Offline

#9 2015-03-18 10:39:59

fjvinal
Member
From: Madrid
Registered: 2012-06-23
Posts: 45

Re: An USB stick that can boot both in UEFI and BIOS mode

This is my boot file strcuture. I hope this could help:

#ls -R /boot
/boot:
EFI/                           initramfs-linux-grsec-fallback.img*  initramfs-linux.img*  lost+found/  syslinux/       vmlinuz-linux-grsec*
initramfs-linux-fallback.img*  initramfs-linux-grsec.img*           intel-ucode.img*      memtest86+/  vmlinuz-linux*

/boot/EFI:
boot/

/boot/EFI/boot:
bootx64.efi*  cpu.c32*        dmitest.c32*   hexdump.c32*   kontron_wdt.c32*  libutil.c32*  pci.c32*       reboot.c32*    syslinux.efi*
cat.c32*      cpuid.c32*      elf.c32*       host.c32*      ldlinux.e64*      linux.c32*    pcitest.c32*   rosh.c32*      vesa.c32*
chain.c32*    cpuidtest.c32*  es.ktl*        ifcpu64.c32*   lfs.c32*          ls.c32*       pmload.c32*    sanboot.c32*   vesainfo.c32*
cmd.c32*      debug.c32*      ethersel.c32*  ifcpu.c32*     libcom32.c32*     lua.c32*      poweroff.c32*  sdi.c32*       vesamenu.c32*
cmenu.c32*    dhcp.c32*       gfxboot.c32*   ifmemdsk.c32*  libgpl.c32*       mboot.c32*    prdhcp.c32*    sysdump.c32*   vpdtest.c32*
config.c32*   disk.c32*       gpxecmd.c32*   ifplop.c32*    liblua.c32*       meminfo.c32*  pwd.c32*       syslinux.c32*  whichsys.c32*
cptime.c32*   dmi.c32*        hdt.c32*       kbdmap.c32*    libmenu.c32*      menu.c32*     pxechn.c32*    syslinux.cfg*  zzjson.c32*

/boot/lost+found:

/boot/memtest86+:
cat.c32*    cmd.c32*    config.c32*  cpu.c32*    cpuidtest.c32*  dhcp.c32*  dmi.c32*      SYSLINUX_AUTOUPDATE*
chain.c32*  cmenu.c32*  cptime.c32*  cpuid.c32*  debug.c32*      disk.c32*  memtest.bin*

/boot/syslinux:
cat.c32*        debug.c32*     gpxecmd.c32*   kontron_wdt.c32*  linux.c32*    pmload.c32*    sdi.c32*               vesamenu.c32*
chain.c32*      dhcp.c32*      hdt.c32*       ldlinux.c32*      ls.c32*       poweroff.c32*  sysdump.c32*           vpdtest.c32*
cmd.c32*        disk.c32*      hexdump.c32*   ldlinux.sys*      lua.c32*      poweroff.com*  SYSLINUX_AUTOUPDATE*   whichsys.c32*
cmenu.c32*      dmi.c32*       host.c32*      lfs.c32*          mboot.c32*    prdhcp.c32*    syslinux.c32*          zzjson.c32*
config.c32*     dmitest.c32*   ifcpu64.c32*   libcom32.c32*     meminfo.c32*  pwd.c32*       syslinux.cfg*
cptime.c32*     elf.c32*       ifcpu.c32*     libgpl.c32*       menu.c32*     pxechn.c32*    syslinux.cfg.pacorig*
cpu.c32*        es.ktl*        ifmemdsk.c32*  liblua.c32*       pci.c32*      reboot.c32*    syslinux.cfg.pacsave*
cpuid.c32*      ethersel.c32*  ifplop.c32*    libmenu.c32*      pci.ids*      rosh.c32*      vesa.c32*
cpuidtest.c32*  gfxboot.c32*   kbdmap.c32*    libutil.c32*      pcitest.c32*  sanboot.c32*   vesainfo.c32*

Offline

#10 2015-03-18 12:36:50

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: An USB stick that can boot both in UEFI and BIOS mode

Oops, I made a mistake in my previous post. The UEFI loader (files copied from /usr/lib/syslinux/efi64) goes into /boot/EFI/boot, not /boot/EFI.

Offline

#11 2015-03-18 13:39:57

hifi25nl
Member
Registered: 2011-05-07
Posts: 263

Re: An USB stick that can boot both in UEFI and BIOS mode

I discovered this morning before reading the post!

I have tried uefi with an iMAC with radeon card.

It will start but...:
1) No syslinux boot menu. Archlinux is starting directly to the default kernel, I suppose.
Yes, I have copied all files from /usr/lib/syslinux/efi64 (and UI menu.c32 enabled in syslinux.cfg inside /boot/EFI/boot)
2) Black screen after systemd 218 line on the screen. This is probably a problem about radeon drivers that I need to fix, if possible.
If I start with nomodeset in the kernel line I have an error about radeon driver but I see that systemd services are starting, so the root directory is accessed correctly.

Last edited by hifi25nl (2015-03-18 15:06:28)

Offline

Board footer

Powered by FluxBB