From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id gITyMENkpl++MgAA0tVLHw (envelope-from ) for ; Sat, 07 Nov 2020 09:09:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id hcKsLENkpl8bbAAAbx9fmQ (envelope-from ) for ; Sat, 07 Nov 2020 09:09:23 +0000 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 1642C9403E8 for ; Sat, 7 Nov 2020 09:09:22 +0000 (UTC) Received: from localhost ([::1]:33984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbKDp-0000ng-HZ for larch@yhetil.org; Sat, 07 Nov 2020 04:09:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbKDW-0000nL-9M for bug-guix@gnu.org; Sat, 07 Nov 2020 04:09:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kbKDV-0000wm-Tr for bug-guix@gnu.org; Sat, 07 Nov 2020 04:09:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kbKDV-0005iC-Oi for bug-guix@gnu.org; Sat, 07 Nov 2020 04:09:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#44353: guix system disk-image -t raw fails with grub-efi-bootloader Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 07 Nov 2020 09:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44353 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: Maxim Cournoyer Received: via spool by 44353-submit@debbugs.gnu.org id=B44353.160474012521931 (code B ref 44353); Sat, 07 Nov 2020 09:09:01 +0000 Received: (at 44353) by debbugs.gnu.org; 7 Nov 2020 09:08:45 +0000 Received: from localhost ([127.0.0.1]:57938 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbKDF-0005hf-DN for submit@debbugs.gnu.org; Sat, 07 Nov 2020 04:08:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kbKDE-0005hS-00 for 44353@debbugs.gnu.org; Sat, 07 Nov 2020 04:08:44 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55470) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbKD8-0000oT-Bk; Sat, 07 Nov 2020 04:08:38 -0500 Received: from [2a01:e0a:19b:d9a0:9dba:8b9f:8322:f2bc] (port=39664 helo=cervin) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kbKD7-0004QX-QB; Sat, 07 Nov 2020 04:08:38 -0500 From: Mathieu Othacehe References: <1e589f3b-47f8-fd53-b750-d2beff8d91f5@gmail.com> <87lffdtzh1.fsf@gmail.com> Date: Sat, 07 Nov 2020 10:08:36 +0100 In-Reply-To: <87lffdtzh1.fsf@gmail.com> (Maxim Cournoyer's message of "Sat, 07 Nov 2020 02:09:30 -0500") Message-ID: <875z6hmt4b.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 44353@debbugs.gnu.org, Jesse Gibbons Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: OKssheHx0fKl --=-=-= Content-Type: text/plain Hello Maxim, Thanks for your patch! It's hard to provide a reliable abstraction on top of all the exotic bootloader installation methods existing. Currently, each bootloader implements two methods: * bootloader-installer * bootloader-disk-image-installer The first one is dedicated to the installation of the bootloader on a mounted directory, while the second one is meant to work on a disk device such as "/dev/sda" or directly on a disk-image. When producing a disk-image with the "raw" type, we are always creating and populating an ESP partition (see raw-image-type), regardless of the selected bootloader. In fact, "raw" should be renamed to "hybrid-efi". The produced image can work on machines with legacy mbr boot or with EFI boot. Hence, calling "install-grub-efi" like it's done while building the lightweight-desktop operating-system is useless and fails. The attached patch fixes it. You can test it with: --8<---------------cut here---------------start------------->8--- qemu-system-x86_64 -m 1024 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -hda disk.img --8<---------------cut here---------------end--------------->8--- > + ;; Special case: most bootloaders can be copied > + ;; directly at some fixed location on the image > + ;; disk, but when installed to the master boot > + ;; record (MBR), GRUB requires support files > + ;; present under /boot/grub, which is handled by > + ;; its 'installer' procedure. > #:bootloader-installer > - #+(bootloader-installer bootloader) > + #+(if (eq? 'grub (bootloader-name bootloader)) > + (bootloader-installer bootloader) > + #f) That would prevent other bootloaders relying on this procedure to work, such as extlinux. Thanks, Mathieu --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-bootloader-grub-Fix-EFI-installation.patch >From 2145fc40d3eb949885ce94883b09c7291c607be6 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sat, 7 Nov 2020 10:03:53 +0100 Subject: [PATCH] bootloader: grub: Fix EFI installation. When producing a disk-image, "install-grub-efi" will be called with EFI-DIR set to false. The EFI bootloader is already installed by "initialize-efi-partition". In that case, do not proceed to bootloader installation. Fixes: . * gnu/bootloader/grub.scm (install-grub-efi): Do not install the bootloader if EFI-DIR is false. --- gnu/bootloader/grub.scm | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 0899fab61f..3404456df9 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -574,20 +574,24 @@ fi~%")))) (define install-grub-efi #~(lambda (bootloader efi-dir mount-point) ;; 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 - "--bootloader-id=Guix" - "--efi-directory" target-esp)))) + ;; system whose root is mounted at MOUNT-POINT. When producing a + ;; disk-image, EFI-DIR is false and the EFI bootloader is already + ;; installed using "initialize-efi-partition". + (when efi-dir + (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 + "--bootloader-id=Guix" + "--efi-directory" target-esp))))) (define (install-grub-efi-netboot subdir) "Define a grub-efi-netboot bootloader installer for installation in SUBDIR, -- 2.29.2 --=-=-=--