You are not logged in.

#1 2023-10-19 17:54:30

bedtime
Member
Registered: 2019-02-12
Posts: 68

Can't get EFISTUB to boot

I'd like to get my computer to boot with just EFISTUB directly and not have to use a bootloader. I got this working yesterday, but can't remember exactly what I did. I was doing a combination of these two tutorials:

https://wiki.archlinux.org/title/Unified_kernel_image
https://wiki.archlinux.org/title/EFISTUB

My ESP is mounted on /efi, and I'm thinking this might be part of the problem, but it was like that yesterday too, when it was working.

/etc/fstab:

# /dev/sda3 LABEL=ROOT
UUID=4d094fe7-de67-4c91-a0fb-877c271eb1bf       /               btrfs           rw,noatime,compress-force=zstd:1,discard=async,space_cache=v2,subvol=/@   0 0

# /dev/sda1 LABEL=EFI
UUID=B4C7-3FDF          /efi            vfat            rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro     0 2

# /dev/sda2
UUID=fe22038a-28d1-4a1f-b7e4-5944f3059a4b none swap defaults 0 0

/etc/mkinitcpio.d/linux.preset:

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux"
ALL_microcode=(/boot/*-ucode.img)

PRESETS=("default")

default_image="/efi/EFI/arch/initramfs-linux.img"
#default_image="/boot/initramfs-linux.img"
default_uki="/efi/EFI/Linux/arch-linux.efi"

Then I ran:

# mkdir -p /efi/EFI/{arch,Linux}
# cp /boot/initramfs-linux.img /efi/EFI/arch/initramfs-linux.img
# efibootmgr --create --disk /dev/sda --part 1 --label "Arch Linux" --loader /EFI/vmlinuz-linux --unicode "root= UUID=4d094fe7-de67-4c91-a0fb-877c271eb1bf  rw resume=UUID=fe22038a-28d1-4a1f-b7e4-5944f3059a4b initrd=\EFI\arch\initramfs-linux.img" -o 0004,0007,0003
# mkinitcpio -p linux
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
==> Using configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -U /efi/EFI/Linux/arch-linux.efi -g /efi/EFI/arch/initramfs-linux.img --microcode /boot/intel-ucode.img
==> Starting build: '6.5.7-arch1-1'
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [keyboard]
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
  -> Running build hook: [autodetect]
  -> Running build hook: [kms]
  -> Running build hook: [modconf]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
==> WARNING: consolefont: no font found in configuration
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [liveroot]
  -> Running build hook: [resume]
==> Generating module dependencies
==> Creating lz4-compressed initcpio image: '/efi/EFI/arch/initramfs-linux.img'
==> Image generation successful
==> Creating unified kernel image: '/efi/EFI/Linux/arch-linux.efi'
  -> Using UEFI stub: '/usr/lib/systemd/boot/efi/linuxx64.efi.stub'
  -> Using os-release file: '/etc/os-release'
  -> Using cmdline file: '/etc/kernel/cmdline'
  -> Using kernel image: '/boot/vmlinuz-linux'
  -> Using microcode image: '/boot/intel-ucode.img'
==> Unified kernel image generation successful

After this, my computer doesn't boot it. It will just revert back to the boot list.

Offline

#2 2023-10-19 19:06:08

-thc
Member
Registered: 2017-03-15
Posts: 516

Re: Can't get EFISTUB to boot

bedtime wrote:

My ESP is mounted on /efi, and I'm thinking this might be part of the problem [...]

No.

bedtime wrote:

/etc/mkinitcpio.d/linux.preset:

ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-linux"
ALL_microcode=(/boot/*-ucode.img)

PRESETS=("default")

default_image="/efi/EFI/arch/initramfs-linux.img"
#default_image="/boot/initramfs-linux.img"
default_uki="/efi/EFI/Linux/arch-linux.efi"

Why do you drop the files into different directories? Just to make things more complicated?

bedtime wrote:

Then I ran:

# mkdir -p /efi/EFI/{arch,Linux}
# cp /boot/initramfs-linux.img /efi/EFI/arch/initramfs-linux.img
# efibootmgr --create --disk /dev/sda --part 1 --label "Arch Linux" --loader /EFI/vmlinuz-linux --unicode "root= UUID=4d094fe7-de67-4c91-a0fb-877c271eb1bf  rw resume=UUID=fe22038a-28d1-4a1f-b7e4-5944f3059a4b initrd=\EFI\arch\initramfs-linux.img" -o 0004,0007,0003

Why copy an existing initramfs? You already create this one in the last (mkinitcpio) step.
Why does this efibootmgr command create an EFI boot manager entry and sets the boot order at the same time?
How many boot entries exist and is the newly created one the entry "0004"?
Why does the "loader" option point to an EFI binary (UKI) that is not created in the last (mkinitcpio) step?

Offline

#3 2023-10-19 20:40:39

bedtime
Member
Registered: 2019-02-12
Posts: 68

Re: Can't get EFISTUB to boot

Thanks for much for the though-provoking questions! They got me thinking.

-thc wrote:

Why do you drop the files into different directories? Just to make things more complicated?

I did that after things started to not work. And I saw another tutorial that did it this way. I'd rather not have it complicated though.

Why copy an existing initramfs? You already create this one in the last (mkinitcpio) step.

There was no good purpose for that. I think I did that initially.

Why does this efibootmgr command create an EFI boot manager entry and sets the boot order at the same time?

I thought that you needed to say the boot order or it wouldn't boot the proper device.

How many boot entries exist and is the newly created one the entry "0004"?

There are dozens and dozens. Each time I run the command another appears.

Why does the "loader" option point to an EFI binary (UKI) that is not created in the last (mkinitcpio) step?

Do I need a uki for this to work? I didn't see that in the EFISTUB article, but I'm desperate, so trying anything.

As of now, I repartitioned the disk to have the first vfat partition as /boot, instead of /efi. I thought this might simplify things a little.

That said, now I'm wondering if there needs to be an efi directory for this to work. I'm assuming there needs to be one, but I'm not sure. If there needs to be one, then I'm assuming I need to make an image there.

As for the actual system files in general, they seem to be fine. When I install refind, everything boots up fine, but I'd rather not have a boot manager if I don't need one.

Last edited by bedtime (2023-10-19 20:42:17)

Offline

#4 2023-10-20 05:35:29

-thc
Member
Registered: 2017-03-15
Posts: 516

Re: Can't get EFISTUB to boot

bedtime wrote:

There are dozens and dozens. Each time I run the command another appears.

This may lead to running out of storage space on your mainboard (Like here).
Please remove all unneeded entries.

And for the future: If a valid EFI boot manager entry for your UKI kernel already exists you do not need to create another one.

bedtime wrote:

As of now, I repartitioned the disk to have the first vfat partition as /boot, instead of /efi. I thought this might simplify things a little.

That said, now I'm wondering if there needs to be an efi directory for this to work. I'm assuming there needs to be one, but I'm not sure. If there needs to be one, then I'm assuming I need to make an image there.

You have a boot and an EFI partition? Or do you mount the EFI partition as "/boot"? Why format a boot partition as vfat?

bedtime wrote:

As for the actual system files in general, they seem to be fine. When I install refind, everything boots up fine, but I'd rather not have a boot manager if I don't need one.

But reFind may use different files and/or different partitions and is not very useful for comparison.

Offline

#5 2023-10-21 18:06:55

theRedCyclops
Member
Registered: 2022-06-17
Posts: 5

Re: Can't get EFISTUB to boot

I think the issue that you are encountering may be that you enabled the Unified Kernel Image, disabled the regular image and then tried creating a boot entry to the original image. If you want to do it using EFISTUB you probably have to switch them back to the original state.

Last edited by theRedCyclops (2023-10-21 18:07:53)

Offline

#6 2023-10-22 14:11:30

bedtime
Member
Registered: 2019-02-12
Posts: 68

Re: Can't get EFISTUB to boot

-thc wrote:

Please remove all unneeded entries.

And for the future: If a valid EFI boot manager entry for your UKI kernel already exists you do not need to create another one.

Done and noted.

You have a boot and an EFI partition? Or do you mount the EFI partition as "/boot"? Why format a boot partition as vfat?

I can have either. I'm not sure what's best. I hear that having an exclusive /efi directory formatted as vfat is best, so that's what I'm using now.

But reFind may use different files and/or different partitions and is not very useful for comparison.

Yep, I'm figuring that out.

I think the issue that you are encountering may be that you enabled the Unified Kernel Image, disabled the regular imageand then tried creating a boot entry to the original image. If you want to do it using EFISTUB you probably have to switch them back to the original state.

Thanks. Will do.

If there as just a straight forward way to do this, I could get it done, but I suppose there are so many different ways to do it that it's not really feasible.

Offline

Board footer

Powered by FluxBB