From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id OHzCAdxAjmIChwAAbAwnHQ (envelope-from ) for ; Wed, 25 May 2022 16:44:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mDKoANxAjmI/bAEAG6o9tA (envelope-from ) for ; Wed, 25 May 2022 16:44:44 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 81BB6979D for ; Wed, 25 May 2022 16:44:43 +0200 (CEST) Received: from localhost ([::1]:36790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntsFe-0002r6-9m for larch@yhetil.org; Wed, 25 May 2022 10:44:42 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653489883; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=UkVS0EkiSlahKPYfZqBv0R64tVxIYZOpcAGSO6m/SSY=; b=CCweJeAIvtUFnFMYgaJChNKM9nVOmXDukTZJ83wSm19KMTlh8EQVdhVi4O+Px5dFNHRiig HK7CP2MBtN0fLWdqS5QXnJPk60g+k0ojeARkeAAX5d7YYyjsckVYEKF+j8SUGTNxkQADIN 0F9UGIxLxwkv/4g/B7cEhbM1388VUGBe21OsGNrPxNf2lzRfJ1AcNOa+wZjMWoczt1tRFo rWVDRLQB0H4uo79nH0WPKb2f+CoF6DMLWVbqm+BgKq/M+YbhmsU3VqNOjqFdt7DvQ5Cvpu ej/C+g3y1TB0EN/Y15DIP64l/eauMb1HMxUKoPjPA//DZhME8OyP+0cbFIqfKw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653489883; a=rsa-sha256; cv=none; b=Dsqc/FhzBvxMX6eyMxsrUtNcC80bFaGcFI7vLvCzRGMmdZQlUcuK0acpUta/I0v6W+N2FF eSHBsmRtWMj5Whrh76QaaxNy6gcdBKLBLyJ3iFch/7HxndwW97ohNIvWefj97mafNnft6n aDEFZcM86Ml/CAOo4QNhz214Y+uZVAWWuUkV0oJ2uIUwZpZn1vypgcE54LnARIdKUklglD 6zV/MOHgsrGvGkdzz9HLQ3s7hq/JRYkLCRYsFDchEYTqSNsFh4Y38VSPMmgePIPTtFq0f/ +L4bV8JA68GmKBJ1YF/YijmWTaBN/yPB08hbmKtV6btY5VSA5EOBN8lsTDHSuQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=hallsby-com.20210112.gappssmtp.com header.s=20210112 header.b="FW/pE+BU"; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 0.16 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=hallsby-com.20210112.gappssmtp.com header.s=20210112 header.b="FW/pE+BU"; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 81BB6979D X-Spam-Score: 0.16 X-Migadu-Scanner: scn0.migadu.com X-TUID: InlzS9Djytt9 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(+) 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) base-commit: d129d962e437fd215c5e9428fc1b26e2d72ffbda -- 2.36.1