Skip to content
Snippets Groups Projects

Draft: RFC: add package that installs grub-efi images

Closed Imported Administrator requested to merge grub-img into master
6 unresolved threads

This generates grub efi application images for multiple archs, and allows installing a grub efi image on a host with a different arch (e.g. x86 efi app on x86_64 system)

I'm pretty sure that using arch="any", etc is not the best way to package this, so I'm open to suggestions.

Also, maybe something like this would fit better in Alpine, but I wanted to make the MR here so we can discuss it more.

This depends on https://gitlab.com/postmarketOS/boot-deploy/-/merge_requests/27, this branch includes a boot-deploy APKBUILD patch to build boot-deploy with the branch in that MR.

This also requires a pmbootstrap patch.

I'm not happy with how deviceinfo vars for boot stuff have been handled (using generate in the name for those vars is kinda misleading, imho). I would much rather use some format for those vars like: deviceinfo_<bootloader>_<bootloader-specific config used by bootdeploy>, and so I used new vars with this format in both the patch here, the changes in boot-deploy, and the patch in pmbootstrap that I'll submit on the mailing list shortly.

The motivation for this is to simplify how pmOS configures x86 and x86_64 systems that use EFI boot. With this change, device packages will no longer need to provide a grub.cfg, or generate a grub EFI app image. boot-deploy is able to also properly inject kernel cmdline params from deviceinfo too (currently device packages that provide a grub.cfg are hard-coding kernel cmdline params...)

pmbootstrap patch: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230507022014.25135-1-clayton%40craftyguy.net%3E

Edited by Administrator

Merge request reports

Checking pipeline status.

Approval is optional

Closed by AdministratorAdministrator 1 year ago (Aug 23, 2023 12:35am UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Administrator changed the description · Imported

    changed the description

    By clayton craft on 2023-05-07T02:16:52

  • Administrator changed the description · Imported

    changed the description

    By clayton craft on 2023-05-07T02:20:48

    • Author Owner

      This will obviously require changes to other x86 / x86_64 devices that EFI boot, but I'll hold off on making those changes until we can agree whether this approach is good, or if further changes are necessary. This way I don't have to rebase constantly to keep a collection of device packages updated in this branch :sweat_smile:

      By clayton craft on 2023-05-07T02:22:00

  • Administrator
    Administrator @root started a thread on the diff
21 _mkimage() {
22
23 mkdir -p "$srcdir/out"
24
25 local _grub_arch="$1"
26 local _efi_arch=
27 case "$1" in
28 x86_64)
29 _efi_arch="x64"
30 ;;
31 i386)
32 _efi_arch="ia32"
33 ;;
34 esac
35
36 grub-mkimage \
  • Author Owner

    Why don't we do this in boot-deploy?

    By jenneron on 2023-05-07T02:23:19

  • Author Owner

    yeah I submitted a patch for that, but then replaced it.

    I didn't like having to deal with the grub-early.cfg in boot-deploy, but maybe going back to that is simpler?

    By clayton craft on 2023-05-07T02:26:15

  • Author Owner

    I still don't see any reasons to use grub-early.cfg

    By jenneron on 2023-05-07T02:27:33

  • Author Owner

    oh really? I thought it was required for finding the grub root partition (/boot, not the OS rootfs). If it's actually not needed, then that would make this a bit easier :)

    By clayton craft on 2023-05-07T02:29:08

  • Author Owner

    I've just figured out there may be a reason (see the thread about grub-early.cfg)

    By jenneron on 2023-05-07T02:30:05

  • Author Owner

    another reason to not do this in boot-deploy, is taht it would require installing grub on the system, at least in the rootfs (grub-install shouldn't be run... since boot-deploy would handle that part). So having grub laying around in the rootfs would take up space and it might be confusing to someone who sees it and thinks that pmOS is using grub-install, etc.

    By clayton craft on 2023-05-07T05:13:35

  • Please register or sign in to reply
  • Administrator
    Administrator @root started a thread on the diff
  • 18
    19 # Generates a grub efi app in $srcdir/out
    20 # $1: grub arch
    21 _mkimage() {
    22
    23 mkdir -p "$srcdir/out"
    24
    25 local _grub_arch="$1"
    26 local _efi_arch=
    27 case "$1" in
    28 x86_64)
    29 _efi_arch="x64"
    30 ;;
    31 i386)
    32 _efi_arch="ia32"
    33 ;;
    • Author Owner

      If we do it this way, it should support more arches

      By jenneron on 2023-05-07T02:23:19

    • Author Owner

      sure, but let's only limit it right now to those that we can actually test. I don't have any other archs that I would want to EFI boot grub on. Can you help?

      By clayton craft on 2023-05-07T02:24:51

    • Author Owner

      I only have surface rt on armv7

      By jenneron on 2023-05-07T02:27:33

    • Please register or sign in to reply
  • Administrator
    Administrator @root started a thread on the diff
  • 1 search --no-floppy --set=root --label "pmOS_boot"
    • Author Owner

      Ok right off the bat I can see that the way this grub-efi-img package is configured won't work since it's trying to build on other archs, which makes sense... lol.

      Another idea I had was to generate the efi image for both x86 and x86_64 and have a single package that targets archs x86 and x86_64...

      By clayton craft on 2023-05-07T02:24:05

  • Administrator marked this merge request as draft · Imported

    marked this merge request as draft

    By clayton craft on 2023-05-23T22:21:35

  • Administrator changed title from Draft: RFC: Draft: add package that installs grub-efi images to Draft: RFC: add package that installs grub-efi images · Imported

    changed title from Draft: RFC: Draft: add package that installs grub-efi images to Draft: RFC: add package that installs grub-efi images

    By clayton craft on 2023-05-23T22:21:50

    • Author Owner

      Regarding grub-early.cfg: we need to generate this in boot-deploy, so we can put the UUID of the partition where grub lies into it, so grub loads the modules from the correct partition.

      Right now we have in cross/grub-x86/grub_early.cfg:

      search --no-floppy --set=root --label "pmOS_boot"
      set prefix=($root)/grub

      But this leads to problems when there are two partitions with a pmOS_boot label, e.g. after installing to eMMC and booting from SD card.

      Related: #1531

      By Oliver Smith on 2023-06-04T07:35:35

      Edited by Ghost User
    • Author Owner

      (meant to make this a blocking thread)

      By Oliver Smith on 2023-06-04T07:35:35

    • Author Owner

      Ok, generating this in boot-deploy is easy, I have a branch somewhere that does it

      By clayton craft on 2023-06-06T12:50:43

    • Please register or sign in to reply
  • Administrator added status::mr-stale label · Imported

    added status::mr-stale label

  • Author Owner

    Sorry to bother you @craftyguy,

    but we've detected that this merge request hasn't seen any recent activity. If you need help or want to discuss your approach with developers you can ping @postmarketOS. You can also ask on matrix in #devel:postmarketos.org or #postmarketos-devel on OFTC. If no further activity occurs in this MR, postmarketOS developers may close it in the future.

    Thanks for your contribution.

    By * postmarketOS Bot on 2023-07-06T13:00:02

  • Administrator closed · Imported

    closed

  • Author Owner

    closing, will submit a new MR later with patches that implement this a bit differently

    By clayton craft on 2023-08-23T00:36:41

  • Please register or sign in to reply
    Loading