You are not logged in.

#1 2015-05-15 13:29:15

awbs
Member
Registered: 2013-01-18
Posts: 27

[Solved] Unbootable USB with both BIOS and UEFI setup

I'm installing Arch to a USB flash drive to be bootable across a wide-range of computers (like the Arch ISO for USB) - both with legacy BIOS and with UEFI support (32bit instead of 64bit for greatest compatibility). I've installed Arch successfully and everything with it works fine.

To get the flash drive to bootup on legacy BIOS systems, I've installed Grub. This went without a hitch and this boots up on every legacy BIOS machine I've tried.

However, I cannot for the life of me get UEFI working. I only have one UEFI-enabled machine to test on. I've tied settings up both Gummiboot and Grub for UEFI support and they both seem to get to the same place. I get their boot entries to show up in the UEFI's boot up menu, but it boots the UEFI installation already present on the system (another Arch installation). If I remove the UEFI entry for the Arch installation on the machine, it lists the flash drive in the boot-up menu but clicking on it tells me that there were no bootable mediums found. So I'm guessing there is a configuration error somewhere.

The Arch ISO disk boots up successfully over UEFI on the machine without a hitch. SafeBoot is disabled on the UEFI machine machine. The UEFI machine has a working UEFI Arch installation by Grub2 which works fine - I setup the flash drive pretty much the same was as detailed below but it doesn't work.

Here is my setup:

Disk /dev/sda: 57.9 GiB, 62176362496 bytes, 121438208 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: 7AF2949B-01DA-4A5D-96B5-C716601BF56B

Device        Start       End   Sectors  Size Type
/dev/sda1      2048  10487807  10485760    5G EFI System
/dev/sda2  10487808  10489855      2048    1M BIOS boot
/dev/sda3  10489856 121438174 110948319 52.9G Linux filesystem

It is a GPT formatted flash drive, with an EFI partition, a BIOS Boot partition (for Grub) and finally a LUKS encrypted file system. (I have also tried the system without LUKS and I still get the same results as above).

ESP partition with Gummiboot (/boot): (ls -LR /boot)

EFI  grub  initramfs-linux-fallback.img  initramfs-linux.img  intel-ucode.img  loader  vmlinuz-linux

./EFI:
Boot  gummiboot

./EFI/Boot:
BOOTIA32.EFI BOOTX64.efi

./EFI/gummiboot:
gummibootia32.efi

./loader:
entries  loader.conf

./loader/entries:
arch.conf

(with BOOTIA32.EFI copied to BOOTX64.EFI so UEFI would recognize the flash drive.)

ESP partition with Grub (/boot): (ls -LR /boot)

EFI  grub  initramfs-linux-fallback.img  initramfs-linux.img  intel-ucode.img  loader  vmlinuz-linux

./EFI:
Boot  gummiboot

./EFI/boot:
bootx64.efi

./EFI/grub:
grubia32.efi
grub.efi

I've tried copying both grub.efi to bootx64.efi and grubia32.efi to bootx64.efi. Both seem to be the same file.

BLKID

/dev/sda1: UUID="E3BA-7D68" TYPE="vfat" PARTLABEL="EFI System" PARTUUID="d3619522-56c7-4a18-9997-3a9649809506"
/dev/sda2: PARTLABEL="BIOS boot partition" PARTUUID="40132eb6-2994-44b8-a6c4-8380fbd45a98"
/dev/sda3: UUID="a7392099-0853-4b03-a1e9-82e298eaab95" TYPE="crypto_LUKS" PARTLABEL="Linux filesystem" PARTUUID="300f4171-f1b5-4407-beee-060ae8fb8dee"
/dev/mapper/Root: LABEL="Root" UUID="679ba330-de69-4805-ba12-59d479ea12fc" TYPE="ext4"

fstab (using default mount options from fstab generator)

#
# /etc/fstab: static file system information
#
# <file system>    <dir>    <type>    <options>    <dump>    <pass>

# /dev/mapper/Root LABEL=Root
UUID=679ba330-de69-4805-ba12-59d479ea12fc    /             ext4          defaults,relatime    0 1

# /dev/sda1
UUID=E3BA-7D68          /boot         vfat          rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro    0 2

Grub for legacy BIOS was setup with the commands:

grub-install --target=i386-pc --recheck --debug /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Grub configuration from /boot/grub/grub.cfg

GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=a7392099-0853-4b03-a1e9-82e298eaab95:Root"

--

I've tried both Gummiboot and Grub2 (not at the same time) alongside Grub for the legacy BIOS bootup. BIOS bootup works fine.

UEFI configuration with Gummiboot:

gummiboot --path=/boot install

/boot/loader/loader.conf

default  arch
timeout  4

/boot/loader/entries/arch.conf

title    Arch Linux
linux    /vmlinuz-linux
initrd    /initramfs-linux.img
options cryptdevice=PARTUUID=300f4171-f1b5-4407-beee-060ae8fb8dee:Root root=UUID=679ba330-de69-4805-ba12-59d479ea12fc ro

UEFI Configuration with GRUB2:

grub-install --target=i386-efi --efi-directory=/boot --bootloader-id=grub --recheck
grub-mkconfig -o /boot/grub/grub.cfg
mkdir /boot/EFI/boot
cp /boot/EFI/grub/grubia32.efi  /boot/EFI/boot/bootx64.efi

I have to copy grubia32.efi to bootx64.efi so my UEFI system detects the flash drive.

I have done all of these steps on a BIOS machine, and a UEFI machine, both with the same results. The machine recognizes the flash drive in the bootup menu and lists it as an option to boot from, but it tells me no bootable device was found. I don't care which method I need to use to get the flash drive to bootup over UEFI, gummiboot or Grub, I'm just trying to get it to work.

Last edited by awbs (2015-05-17 18:25:19)

Offline

#2 2015-05-15 13:57:34

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,416

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

The "ia32" vs "x64" when copying should have been a clue.

I have a similar setup, I grab the 64 bit package and install it manually.

Online

#3 2015-05-15 14:01:57

awbs
Member
Registered: 2013-01-18
Posts: 27

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

Scimmia wrote:

The "ia32" vs "x64" when copying should have been a clue.

I have a similar setup, I grab the 64 bit package and install it manually.

I'm not sure I understand. The flash drive is setup as 32bit, so I can't install 64bit - but UEFI will only recognize the flash drive if /boot/efi/boot/bootx64.efi is present.

Offline

#4 2015-05-15 14:04:40

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,416

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

Nearly all UEFI implementations outside of Apple are 64 bit.

Online

#5 2015-05-15 14:07:04

awbs
Member
Registered: 2013-01-18
Posts: 27

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

Scimmia wrote:

Nearly all UEFI implementations outside of Apple are 64 bit.

I'm starting to get the gist of that after what you said earlier - how would you install the bootloader manually though if the system itself is only 32 bit? Would you just extract the 64bit .EFI loaders to the /boot/efi/boot directory?

Edit:

Thank you for your help, by the way.

I downloaded the 64bit version of Gummiboot and extracted the 64bit .EFI loaders and placed them into /boot/efi/boot as bootx64.efi. Gummiboot finally shows up after selecting the flash drive on the UEFI system. However, it just goes back to the gummiboot menu when selecting Arch linux. So I'm going to go over the gummiboot configuration files again to see if I can spot an error somewhere.

Again - thank you for pushing me in the right direction.

Last edited by awbs (2015-05-15 14:14:22)

Offline

#6 2015-05-15 14:13:01

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,416

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

I've never done it with GRUB, but I have with syslinux and gummiboot. Syslinux manual installation is covered on the Wiki page (although copying to /boot/EFI/boot is better than /boot/EFI/syslinux IMO). Gummiboot is simple, just copy the gummiboot/loaders dir to /boot, then copy gummibootx64.efi to /boot/EFI/boot/bootx64.efi

All of that assumes your ESP is mounted to /boot

Last edited by Scimmia (2015-05-15 14:13:36)

Online

#7 2015-05-15 16:24:13

arch9699
Member
Registered: 2015-02-04
Posts: 8

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

It sounds like you are on the right track.  I got it to work using a similar method.  Here is my setup: 16GB USB 2.0 Corsair Voyager.

gdisk -l /dev/sdb

GPT fdisk (gdisk) version 1.0.0

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 31950720 sectors, 15.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 0C83EC1E-9109-4E1E-9EB8-01373E2339D4
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 31950686
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          206847   100.0 MiB   EF02  BIOS boot partition
   2          206848          616447   200.0 MiB   EF00  EFI System
   3          616448        31950686   14.9 GiB    8300  Linux filesystem

As you can see, I made 3 partitions on a GPT labeled USB stick.  You need to format the EF00 and 8300 partitions:

mkfs.vfat -F32 /dev/sdb2
mke2fs -t ext4 -L isofiles /dev/sdb3

"isofiles" is the label I used for the ext4 partition.  You can change this.  Now install Grub for EFI on the ESP partition:

mount /dev/sdb2 /mnt
mkdir -p /mnt/boot
grub-install --target x86_64-efi --efi-directory /mnt --boot-directory /mnt/boot --removable

Place your grub.cfg file in /mnt/EFI/BOOT.
Install GRUB for legacy BIOS on the bios_boot partition:

umount /mnt
mount /dev/sdb3 /mnt
mkdir -p /mnt/boot
grub-install --no-floppy --target i386-pc --boot-directory /mnt/boot /dev/sdb

Place your grub.cfg file in /mnt/boot/grub.  On some systems, it is /mnt/boot/grub2.
Copy all of your ISO files, e.g., arch, gparted, clonzilla, etc, to the ext4 partition.  you will need the UUID of the ext4 partition:

blkid /dev/sdb3

This is because we are using a UUID search method to find the ISO's before loop mounting them. You can obtain the grub menu entries for various distros here.  I used the following grub.cfg to boot arch and gparted in EFI mode:

set default="0"

function load_video {
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_fb
  insmod video_cirrus
  insmod all_video
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=10
submenu 'GParted -->' {
set default="1"
set isofile='/gparted-live-0.22.0-1-amd64.iso'
menuentry 'GParted -- default settings' --class gparted --class gnu-linux --class os {
	search --no-floppy --fs-uuid --set=root THIS_IS_YOUR_UUID
	   loopback loop $isofile
	   set root=loop
	   linuxefi /live/vmlinuz boot=live username=user config components quiet noswap noeject  ip=  nosplash findiso=$isofile
	   initrdefi /live/initrd.img
}
}
submenu 'Arch Linux -->' {
menuentry 'Install Arch Linux' --class arch --class gnu-linux --class os {
	set isofile='/archlinux-2015.04.01-dual.iso'
	search --no-floppy --fs-uuid --set=root YOUR_UUID
	loopback loop $isofile
	set root=loop
	linuxefi /arch/boot/x86_64/vmlinuz archisolabel=ARCH_201504 img_label=isofiles img_loop=$isofile earlymodules=loop
	initrdefi /arch/boot/x86_64/archiso.img
}
}

The legacy grub.cfg file is identical to the above, except that you use "linux" and "initrd" instead of "linuxefi" and "intrdefi".   Note that unfortunately you have to use two grub.cfg file, one for UEFI and the other for legacy placed in the locations described above.  However, they are very similar.

When you boot the machine, if it is an ASUS board, let's assume, press F8 during POST.  You should see "Corsair - UEFI" and "Corsair".  They should both work.  Good Luck.

Offline

#8 2015-05-15 16:28:18

awbs
Member
Registered: 2013-01-18
Posts: 27

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

At work I've been able to bootup the flash drive on another UEFI computer (a Dell Latitude) with Safeboot disabled.

I get to the Gummiboot menu and select Arch, and unlike the previous machine, it gives me an error message:

Error loading \vmlinuz-linux: unsupported

Another user had this same issue https://bbs.archlinux.org/viewtopic.php?id=197141. That was the only Google result which came up when searching the error. They fixed it by reinstalling the kernel. I've done this and made sure it was on the /boot partition (which is my ESP partition). However, reinstalling the kernel does not help. The kernel boots up fine with the legacy BIOS grub, though.

Offline

#9 2015-05-15 16:45:17

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,416

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

Hmm, I wonder if EFI64 will load a 32 bit kernel. I have a 64 bit kernel installed along side my 32 bit kernel.

Online

#10 2015-05-15 16:50:05

awbs
Member
Registered: 2013-01-18
Posts: 27

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

That's what I'm guessing. I'll likely have to enable 64bit packages and see if a 64bit kernel loads fine. Are you able to boot your 32bit kernel?

I'm guessing if I can boot the 32bit kernel over legacy BIOS and the 64bit over UEFI - I'll be just fine. I'll try this and report back to see if that works.

Offline

#11 2015-05-15 16:58:21

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,416

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

I honestly never tried, andI don't have a UEFI system I want to reboot to try it right now.

Having a 64 bit kernel available is a good idea anyway. Without it, you won't be able to chroot into a 64 bit system. I use a 3rd party repo and a separate pacman.conf to make it work.

Edit: thinking about it, a full bootloader like GRUB or Syslinux might be able to do it, even if Gummiboot (stub loader) won't.

Last edited by Scimmia (2015-05-15 17:15:45)

Online

#12 2015-05-17 18:25:06

awbs
Member
Registered: 2013-01-18
Posts: 27

Re: [Solved] Unbootable USB with both BIOS and UEFI setup

Thanks Scimmia - I got it all working.

I switched everything over to 64bit and created a separate smaller 32bit partition with a few utilities we need for 32bit computers.
After switching over to 64bit, legacy BIOS and UEFI booting are working perfectly. Grub also recognizes the 32bit partition and boots from that fine.

Offline

Board footer

Powered by FluxBB