Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

How to configure the UEFI boot options? #126

Closed
rgl opened this issue Sep 15, 2021 · 11 comments
Closed

How to configure the UEFI boot options? #126

rgl opened this issue Sep 15, 2021 · 11 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@rgl
Copy link

rgl commented Sep 15, 2021

To properly install an OS in a UEFI machine we need to reset the existing UEFI boot options and configure UEFI to boot the new OS.

In a regular debian root shell, we can do this as:

# delete all boot options (the BootXXXX UEFI variables).
efibootmgr \
  | perl -n -e '/^Boot([0-9A-F]{4})/ && print "$1\n"' \
  | xargs -I% efibootmgr --quiet --delete-bootnum --bootnum %
efibootmgr --quiet --delete-bootorder
# install the current OS boot option.
grub-install

While trying to transpose this to tinkerbell, I've failed to use the cexec action in this non-working workflow:

version: "0.1"
name: debian
global_timeout: 1800
tasks:
  - name: debian-install
    worker: '{{.device_1}}'
    volumes:
      - /dev:/dev
      - /sys/firmware/efi/efivars:/sys/firmware/efi/efivars
      - /worker:/worker
    actions:
      - name: install
        image: image2disk:v1.0.0
        environment:
          IMG_URL: '{{.img_url}}'
          COMPRESSED: true
          DEST_DISK: '{{.boot_device}}'
      - name: configure-uefi
        image: cexec:v1.0.0
        environment:
          BLOCK_DEVICE: '{{.boot_device}}3'
          FS_TYPE: ext4
          CHROOT: y
          DEFAULT_INTERPRETER: /bin/bash -euxo pipefail -c
          CMD_LINE: |
            # delete all the boot options (the firmware will recover them at the next boot).
            # you can also explicitly install it.
            mount
            efibootmgr
            efibootmgr \
              | perl -n -e '/^Boot([0-9A-F]{4})/ && print "$1\n"' \
              | xargs -I% efibootmgr --quiet --delete-bootnum --bootnum %
            efibootmgr --quiet --delete-bootorder
            grub-install --root-directory=/boot {{.boot_device}}
            efibootmgr
      - name: reboot
        image: reboot

This fails to execute the configure-uefi action because the /sys/firmware/efi/efivars is not mounted in the cexec created chroot:

screenshot

So, how can this be done?

Should a new action for the efibootmgr exist? and only use cexec for running grub-install?

@rgl
Copy link
Author

rgl commented Sep 15, 2021

FWIW, I've created a new reset-uefi-boot action that deletes all the BootXXX UEFI variables with efibootmgr --quiet --delete-bootnum --bootnum and is executed in a workflow like:

version: "0.1"
name: debian
global_timeout: 1800
tasks:
  - name: debian-install
    worker: '{{.device_1}}'
    volumes:
      - /dev:/dev
      - /sys/firmware/efi/efivars:/sys/firmware/efi/efivars
      - /worker:/worker
    actions:
      - name: install
        image: image2disk:v1.0.0
        environment:
          IMG_URL: '{{.img_url}}'
          COMPRESSED: true
          DEST_DISK: '{{.boot_device}}'
      - name: reset-uefi-boot
        image: reset-uefi-boot
      - name: reboot
        image: reboot

@tstromberg tstromberg added the kind/support Categorizes issue or PR as a support question. label Sep 21, 2021
@tstromberg
Copy link
Contributor

@thebsdbox @displague - is this something you could provide insight on?

@displague
Copy link
Member

displague commented Sep 27, 2021

@rgl It looks like this mount point should be available:

Can you change mount to cat /proc/self/mounts (notice how worker is not included, good explanation at https://unix.stackexchange.com/a/91961/105417)

If it is not mounted, can we try mounting manually to see what that looks like:
mount -t efivarfs efivarfs /sys/firmware/efi/efivars

Can we also check that the system is booting into UEFI mode?
Some https://bbs.archlinux.org/viewtopic.php?id=249546

efivar-tester looks to be included with the efivars package.

@displague
Copy link
Member

@thebsdbox will be back later in the week (or next week) and might have other ideas.

@rgl Is your reset-uefi-boot image source available? How does this differ?

@thebsdbox
Copy link
Contributor

This is ace, definitely something that would make sense to add to the hub.

@rgl
Copy link
Author

rgl commented Sep 28, 2021

@displague
Copy link
Member

@rgl Contributing your action sounds good - https://github.com/tinkerbell/hub

@displague
Copy link
Member

Should a new action for the efibootmgr exist? and only use cexec for running grub-install?

In light of your new project, would you say this is safe to close @rgl ?

@rgl
Copy link
Author

rgl commented Nov 18, 2021

Should a new action for the efibootmgr exist? and only use cexec for running grub-install?

In light of your new project, would you say this is safe to close @rgl ?

@displague sorry, what new project?

@nshalman
Copy link
Member

Should a new action for the efibootmgr exist? and only use cexec for running grub-install?

In light of your new project, would you say this is safe to close @rgl ?

@displague sorry, what new project?

I imagine the idea was for you to contribute https://github.com/rgl/rpi-tinkerbell-vagrant/tree/master/actions/reset-uefi-boot to https://github.com/tinkerbell/hub if you're up for it, @rgl.

@mmlb
Copy link
Contributor

mmlb commented Feb 8, 2022

Hey @rgl I think we can close this issue right? Looks like you've figured out how to configure UEFI boot options. We'd love for you to contribute your action to hub, but thats outside of the issue I think.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

7 participants