From patchwork Wed May 25 04:32:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Karl Hallsby X-Patchwork-Id: 39602 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 49E2227BBEA; Wed, 25 May 2022 15:44:42 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id CA44727BBE9 for ; Wed, 25 May 2022 15:44:41 +0100 (BST) Received: from localhost ([::1]:36790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntsFc-0002r6-Tc for patchwork@mira.cbaines.net; Wed, 25 May 2022 10:44:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntrcI-00037w-Rk for guix-patches@gnu.org; Wed, 25 May 2022 10:04:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntrcI-000721-I0 for guix-patches@gnu.org; Wed, 25 May 2022 10:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ntrcI-0008Kg-EF for guix-patches@gnu.org; Wed, 25 May 2022 10:04:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55631] [PATCH] gnu: grub: add removable grub-efi bootloader option Resent-From: Karl Hallsby Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 25 May 2022 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55631 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55631@debbugs.gnu.org Cc: Karl Hallsby X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165348741431949 (code B ref -1); Wed, 25 May 2022 14:04:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 May 2022 14:03:34 +0000 Received: from localhost ([127.0.0.1]:56135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ntrbm-0008J4-Ov for submit@debbugs.gnu.org; Wed, 25 May 2022 10:03:34 -0400 Received: from lists.gnu.org ([209.51.188.17]:59668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ntihu-0006yy-1U for submit@debbugs.gnu.org; Wed, 25 May 2022 00:33:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntiht-0000Ol-LZ for guix-patches@gnu.org; Wed, 25 May 2022 00:33:13 -0400 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]:46719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntihr-0002o7-0s for guix-patches@gnu.org; Wed, 25 May 2022 00:33:13 -0400 Received: by mail-qv1-xf2c.google.com with SMTP id a5so22983qvt.13 for ; Tue, 24 May 2022 21:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hallsby-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UkVS0EkiSlahKPYfZqBv0R64tVxIYZOpcAGSO6m/SSY=; b=FW/pE+BUIxs/j6HGCVDXx3PgbfCfEF96utoVfIEswbGAhgu3SFznajVV8voWXlbEZM F+/DqKqPnTNG26gSmQr038ZINxEl82hjCucY6EZinAzaWazHFJJB4Zi/cNT/gY0ux0cf bD7cP8z4KyYfz/7fcv33b/v6xY29wcZfZosVe5tKarnoV97UQd3G2bUbj+YBnO2hmvGW 69IoruOWoYlWp7C7ZyeMpBdW51l68ODhGys57abBa+G9E4lBoBDUHiYcoX/8KvCMGtF+ 8h4t1pQyjIuQIOHnPgjK4mK39SaG/wuZ6r5NlJsiwA3ApKqhJ2d3CSanbmKCDEK862+L MGlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UkVS0EkiSlahKPYfZqBv0R64tVxIYZOpcAGSO6m/SSY=; b=QnrjGfNVuY4Mysq3qrH0Fk5rzX53D34w+gHISx1OxoAFKfzy8/jmM0xcRgBlTuAwrB tGdNNpT9YzFixRHijZ1yAuHy+aj93lU3wEM4eyMLMHzK/0ZWwiTK5T6/cHuoXVf/B3d7 CgrOhkqEzZNZ7RBLIFNLci7XLb8+GO4ohCIUYCqCiWOQYtvAL4BaGE3GrIbZ1XEOAHUf 8Fr4MQp1B309oEw+oRFiH9mUSExKRsD5gD4IdV3YylQBnfEfAZj1cEkvHXrIcCr2Pql/ 8L35mv2Zyu0pS0L6AJSq8qUZXBKkzNj5CVFoz/88FwyNoDN40atCDd1YKJxDyUMtvCmg d7ow== X-Gm-Message-State: AOAM530paMEYRroJSSr9/G2pi198rIO1VJC8wIJRSaZgQ6NF0GXtw5bi i7kf6E04QAx1IZC7dmoRFSM0Bv5QsID82w== X-Google-Smtp-Source: ABdhPJwuuJF2d87DZ62TSp4xWPEE4Zyk8R0WJw1tCrkaKULgyz4dljJ6LDhAzWlDLlhs+vA/PmjI0Q== X-Received: by 2002:a05:6214:2485:b0:462:4bf3:a817 with SMTP id gi5-20020a056214248500b004624bf3a817mr7759641qvb.82.1653453189434; Tue, 24 May 2022 21:33:09 -0700 (PDT) Received: from localhost.localdomain (1459483-v115.1145-static.batvilaa.metronetinc.net. [192.69.181.148]) by smtp.gmail.com with ESMTPSA id x1-20020a05620a0ec100b0069fc13ce1e9sm640241qkm.26.2022.05.24.21.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 21:33:09 -0700 (PDT) From: Karl Hallsby Date: Tue, 24 May 2022 23:32:54 -0500 Message-Id: <20220525043254.62715-1-karl@hallsby.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Received-SPF: none client-ip=2607:f8b0:4864:20::f2c; envelope-from=karl@hallsby.com; helo=mail-qv1-xf2c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 25 May 2022 10:03:28 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Wed, 25 May 2022 10:44:22 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches For single-disk installs (external USBs) and for amnesiac UEFIs, Guix is not found using its default Grub EFI bootloader location of /boot/efi/EFI/Guix/grubx64.efi means the Guix install will not be found. To handle this, we can place the bootloader file in the UEFI specification location, overwriting any other OS that may have placed a file there. This location is namely /boot/efi/EFI/BOOT/BOOTX64.efi. Grub has explicit support for this location/situation with the `--removable` flag. --- gnu/bootloader/grub.scm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) base-commit: d129d962e437fd215c5e9428fc1b26e2d72ffbda diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 120cd55012..65d7171432 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2020 Stefan +;;; Copyright © 2022 Karl Hallsby ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,10 +51,12 @@ (define-module (gnu bootloader grub) grub-theme-color-highlight grub-theme-gfxmode + install-grub-efi-removable install-grub-efi-netboot grub-bootloader grub-efi-bootloader + grub-efi-removable-bootloader grub-efi-netboot-bootloader grub-mkrescue-bootloader grub-minimal-bootloader @@ -608,6 +611,31 @@ (define install-grub-efi "--bootloader-id=Guix" "--efi-directory" target-esp))))) +(define install-grub-efi-removable + #~(lambda (bootloader efi-dir mount-point) + ;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point + ;; NOTE: efi-dir comes from target list of booloader configuration + ;; There is nothing useful to do when called in the context of a disk + ;; image generation. + (when efi-dir + ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the + ;; system whose root is mounted at MOUNT-POINT. + (let ((grub-install (string-append bootloader "/sbin/grub-install")) + (install-dir (string-append mount-point "/boot")) + ;; When installing Guix, it's common to mount EFI-DIR below + ;; MOUNT-POINT rather than /boot/efi on the live image. + (target-esp (if (file-exists? (string-append mount-point efi-dir)) + (string-append mount-point efi-dir) + efi-dir))) + ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or + ;; root partition. + (setenv "GRUB_ENABLE_CRYPTODISK" "y") + (invoke/quiet grub-install "--boot-directory" install-dir + "--removable" + ;; "--no-nvram" + "--bootloader-id=Guix" + "--efi-directory" target-esp))))) + (define (install-grub-efi-netboot subdir) "Define a grub-efi-netboot bootloader installer for installation in SUBDIR, which is usually efi/Guix or efi/boot." @@ -734,6 +762,12 @@ (define grub-efi-bootloader (name 'grub-efi) (package grub-efi))) +(define grub-efi-removable-bootloader + (bootloader + (inherit grub-efi-bootloader) + (name 'grub-efi-removable-bootloader) + (installer install-grub-efi-removable))) + (define grub-efi-netboot-bootloader (bootloader (inherit grub-efi-bootloader)