Subject: Cannot boot 3.18 with UEFI?

From: RSS <[email-masked]>
Date: Fri, 30 Jun 2023 17:43:32 +0800

Hi,

I am dipping my toe into Alpine, and got it running on an ancient
netbook with 1G of RAM.

My next and current attempt is to get it to work installed in a
partition on a UEFI multi-boot machine. Being kinda new to both Alpine
and UEFI, I am so far not succeeding.

If I use efibootmgr to create a UEFI boot option for my alpine partion,
it silently fails and falls back to the EFI boot menu.

I installed rEFInd from an old Ubuntu partition on the same machine
(rEFInd does not appear to have made it into Alpine stable) but the
rEFInd Boot Manager does not find and present Alpine as a boot
option.

Has anyone seen an Alpine 3.18 default Syslinux install work on UEFI?

I am grasping at straws at this point,
rss

---

From: Ralf Mardorf <[email-masked]>
Date: Fri, 30 Jun 2023 12:30:34 +0200

Hi,

on my new PC I'm forced to use UEFI, since the new Intel GPU doesn't
allow to select CSM, for this reason I migrated from syslinux to grub.
I used syslinux from my Arch Linux install and now I'm using grub from
the Arch Linux install. The pitfalls I experienced booting Alpine were
not related to the grub bootloader.

It's not that terrible as it does sound. Without all those grub configs
for the configs and automation, it's possible to write a clean syslinux
alike config for grub [1].

Regards,
Ralf

• rocketmouse@archlinux ~ 
$ cat /boot/grub/grub.cfg
play 1920 440 1 0 1 880 2 0 1 880 1 0 1 440 2
set timeout=60
set color_normal=light-gray/black
set color_highlight=white/light-gray
set menu_color_normal=light-gray/black
set menu_color_highlight=white/light-gray
set default="1"
insmod efi_gop

menuentry " -- HAL 9000-m1 -----------------------------------------------------------------" {
        true
}

menuentry "    MemTest86 V10+ Free" {
        search --set=root --no-floppy --fs-uuid 3F5B-F698
        chainloader /EFI/memtest86/memtestx64.efi
}

menuentry " -- Arch Linux ------------------------------------------------------------------" {
        true
}

menuentry "    Arch Linux threadirqs" {
        search --no-floppy --set=root --label m1.archlinux
        linux /boot/vmlinuz-linux root=/dev/disk/by-label/m1.archlinux ro threadirqs ibt=off ipv6.disable=1
        initrd /boot/intel-ucode.img /boot/initramfs-linux.img
}

menuentry "    Arch Linux" {
        search --no-floppy --set=root --label m1.archlinux
        linux /boot/vmlinuz-linux root=/dev/disk/by-label/m1.archlinux ro ibt=off ipv6.disable=1
        initrd /boot/intel-ucode.img /boot/initramfs-linux.img
}

menuentry "    Arch Linux Longterm" {
        search --no-floppy --set=root --label m1.archlinux
        linux /boot/vmlinuz-linux-lts root=/dev/disk/by-label/m1.archlinux ro ibt=off ipv6.disable=1
        initrd /boot/intel-ucode.img /boot/initramfs-linux-lts.img
}

menuentry "    Arch Linux Rt" {
        search --no-floppy --set=root --label m1.archlinux
        linux /boot/vmlinuz-linux-rt root=/dev/disk/by-label/m1.archlinux ro ibt=off ipv6.disable=1
        initrd /boot/intel-ucode.img /boot/initramfs-linux-rt.img
}

menuentry " -- Other Linux -----------------------------------------------------------------" {
        true
}

menuentry "    Alpine Linux" {
        search --no-floppy --set=root --label m1.alpine
        linux	/boot/vmlinuz-lts root=/dev/disk/by-label/m1.alpine ro modules=ext4
        initrd	/boot/initramfs-lts
}

menuentry "    Xubu 20.04 Linux 6.2.9-custom" {
        search --no-floppy --set=root --label m1.xubu20.04
        linux	/boot/vmlinuz-6.2.9-custom root=/dev/disk/by-label/m1.xubu20.04 ro
        initrd	/boot/initrd.img-6.2.9-custom
}

menuentry "    Ubuntu X Moon Studio lowlatency" {
        search --no-floppy --set=root --label m1.archlinux
        linux   /.boot/ubuntu_moonstudio/boot/vmlinuz-lowlatency root=/dev/disk/by-label/moonstudio ro
        initrd  /.boot/ubuntu_moonstudio/boot/initrd.img-lowlatency
}

submenu "    *buntu            -- Submenu --" {
    menuentry "    Xubu 20.04 Linux 6.2.9-custom     (recovery mode)" {
            search --no-floppy --set=root --label m1.xubu20.04
            linux	/boot/vmlinuz-6.2.9-custom root=/dev/disk/by-label/m1.xubu20.04 ro recovery nomodeset 
            initrd	/boot/initrd.img-6.2.9-custom
    }
    menuentry "    Xubu 20.04 Linux 5.4.0-42-generic" {
            search --no-floppy --set=root --label m1.xubu20.04
            linux	/boot/vmlinuz-5.4.0-42-generic root=/dev/disk/by-label/m1.xubu20.04 ro
            initrd	/boot/initrd.img-5.4.0-42-generic
    }
    menuentry "    Xubu 20.04 Linux 5.4.0-42-generic (recovery mode)" {
            search --no-floppy --set=root --label m1.xubu20.04
            linux	/boot/vmlinuz-5.4.0-42-generic root=/dev/disk/by-label/m1.xubu20.04 ro recovery nomodeset 
            initrd	/boot/initrd.img-5.4.0-42-generic
    }

    menuentry "    Ubuntu X Moon Studio liquorix threadirqs" {
            search --no-floppy --set=root --label m1.archlinux
            linux   /.boot/ubuntu_moonstudio/boot/vmlinuz-liquorix root=/dev/disk/by-label/moonstudio ro threadirqs
            initrd  /.boot/ubuntu_moonstudio/boot/initrd.img-liquorix
    }
}

menuentry " -- System ----------------------------------------------------------------------" {
        true
}

menuentry "    UEFI Firmware Settings" --id 'uefi-firmware' {
        fwsetup
}

menuentry "    Restart" {
        reboot
}

menuentry "    Shutdown" {
        halt
}

menuentry " --------------------------------------------------------------------------------" {
        true
}

---

From: RSS <[email-masked]>
Date: Mon, 3 Jul 2023 18:12:06 +0800

On Fri, 30 Jun 2023 12:30:34 +0200
Ralf Mardorf <[email-masked]> wrote:

> It's not that terrible as it does sound. Without all those grub
> configs for the configs and automation, it's possible to write a
> clean syslinux alike config for grub [1].

Thanks for the reply, this inspired me to push on, and I do have
progress. I am really stuck on getting to an actual UEFI (eventually
default) boot menu item here, as otherwise my kids will never be able
to safely boot this machine. (What happens when a six-year old plays
with UEFI?: mayhem of the destructive kind. Seen it with my own eyes.
;-)

So I am currently getting Alpine started with rEFInd, which I believe
will not achieve the above default boot objective. Here are my notes,
for posterity and perhaps further comment:

--------------------

Do a surgical single-partition install of Alpine on an already busy
multi-booting machine, and get it booting via UEFI.

The key bit turned out to be in ref 3:

	`If you're going to use EFI, make sure you mount esp partition
	on /boot/efi and set BOOTLOADER=grub and USE_EFI=1, and that
	grub-efi and efibootmgr are installed before running
	setup-disk.`

Where (unspoken!!) `BOOTLOADER=grub and USE_EFI=1` are actually
environment variables which must be set prior to running setup-disk.
There were then promising "EFI" messages as setup-disk did it's stuff,
AND a couple of dodgy looking error messages about not being able to
write files to odd looking locations in the EFI partition.

This STILL somehow did not result in a working UEFI boot entry, but
rEFInd (already installed during earlier struggles) picked it up and is
how I currently boot Alpine.

Ref 5 says this:

	`Note: The loader and initrd file arguments are relative to the
	EFI partition. In a default installation, alpine places these
	files in /boot/, while EFI is mounted to /boot/efi/. You can
	either update fstab to mount EFI at /boot/, or manually copy
	them to /boot/efi/.` 

But, I have tried copying initramfs-lts & vmlinuz-lts into /boot/efi/
to no effect, still no working UEFI boot menu item for Alpine. Mounting
the EFI partition on /boot/ makes me nervous, what bad things then
happen to grub?

Refs:

1.
https://docs.alpinelinux.org/user-handbook/0.1a/Installing/manual.html
2. https://wiki.alpinelinux.org/wiki/Installation 3.
https://wiki.alpinelinux.org/wiki/Setting_up_disks_manually 4.
https://wiki.alpinelinux.org/wiki/Dualbooting 5.
https://wiki.alpinelinux.org/wiki/Bootloaders

---

From: Jakub Jirutka <[email-masked]>
Date: Mon, 3 Jul 2023 12:46:24 +0200

Hi Ralf,

I know I’m a bit later with this response, but you don’t have to use 
Grub for UEFI. Actually, you don’t need any extra bootloader on UEFI.

Linux kernel supports EFISTUB booting which allows EFI firmware to load 
the kernel as an EFI executable. The best way is to build EFI Unified 
Kernel Image – a single EFI PE executable combining an EFI stub loader, 
a kernel image (vmlinuz), the kernel command line, and optionally an 
initramfs image, CPU microcode update, and a splash image. This can be 
easily signed for Secure Boot. It’s described on 
https://wiki.alpinelinux.org/wiki/UEFI_Secure_Boot.

Jakub

---

From: RSS <[email-masked]>
Date: Tue, 11 Jul 2023 16:56:50 +0800

> Linux kernel supports EFISTUB booting which allows EFI firmware to
> load the kernel as an EFI executable. The best way is to build EFI
> Unified Kernel Image – a single EFI PE executable combining an EFI
> stub loader, a kernel image (vmlinuz), the kernel command line, and
> optionally an initramfs image, CPU microcode update, and a splash
> image. This can be easily signed for Secure Boot. It’s described on 

Thanks much for that pointer to this Wiki page, not sure why that did
not turn up in my searches. In fact, the process is not too long or
difficult or all, I just was stumped for a while near the end when

	# efibootmgr --disk <dev> --part 1 --create --label 'Alpine
	Linux' --load /Alpine/linux-lts.efi --verbose

silently refused to do anything. Weird, because I rebooted into Ubuntu
20.04 and ran the exact same command, and it worked. So it looks like
Alpine is a go on this machine, though I wonder if UEFI is entirely
healthy.