summaryrefslogtreecommitdiff
path: root/gnu/bootloader
diff options
context:
space:
mode:
authorKarl Hallsby <karl@hallsby.com>2022-05-24 23:32:54 -0500
committerLudovic Courtès <ludo@gnu.org>2022-06-06 22:43:30 +0200
commit618f665a5ffc6330bc99c4ac2b1077c1e1a7506c (patch)
tree7296eb0052701f42ecb750b50bdcc39b4cbf616f /gnu/bootloader
parente614cf2907105d1d41653c2316b96d29d807baa8 (diff)
bootloader: grub: Add removable grub-efi bootloader option.
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 (install-grub-efi-removable) (grub-efi-removable-bootloader): New variables. * doc/guix.texi (Bootloader Configuration): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/bootloader')
-rw-r--r--gnu/bootloader/grub.scm34
1 files changed, 34 insertions, 0 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 120cd55012b..65d7171432c 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -7,6 +7,7 @@
7;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com> 7;;; Copyright © 2019, 2020 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
8;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> 8;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
9;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de> 9;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de>
10;;; Copyright © 2022 Karl Hallsby <karl@hallsby.com>
10;;; 11;;;
11;;; This file is part of GNU Guix. 12;;; This file is part of GNU Guix.
12;;; 13;;;
@@ -50,10 +51,12 @@
50 grub-theme-color-highlight 51 grub-theme-color-highlight
51 grub-theme-gfxmode 52 grub-theme-gfxmode
52 53
54 install-grub-efi-removable
53 install-grub-efi-netboot 55 install-grub-efi-netboot
54 56
55 grub-bootloader 57 grub-bootloader
56 grub-efi-bootloader 58 grub-efi-bootloader
59 grub-efi-removable-bootloader
57 grub-efi-netboot-bootloader 60 grub-efi-netboot-bootloader
58 grub-mkrescue-bootloader 61 grub-mkrescue-bootloader
59 grub-minimal-bootloader 62 grub-minimal-bootloader
@@ -608,6 +611,31 @@ fi~%"))))
608 "--bootloader-id=Guix" 611 "--bootloader-id=Guix"
609 "--efi-directory" target-esp))))) 612 "--efi-directory" target-esp)))))
610 613
614(define install-grub-efi-removable
615 #~(lambda (bootloader efi-dir mount-point)
616 ;; NOTE: mount-point is /mnt in guix system init /etc/config.scm /mnt/point
617 ;; NOTE: efi-dir comes from target list of booloader configuration
618 ;; There is nothing useful to do when called in the context of a disk
619 ;; image generation.
620 (when efi-dir
621 ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the
622 ;; system whose root is mounted at MOUNT-POINT.
623 (let ((grub-install (string-append bootloader "/sbin/grub-install"))
624 (install-dir (string-append mount-point "/boot"))
625 ;; When installing Guix, it's common to mount EFI-DIR below
626 ;; MOUNT-POINT rather than /boot/efi on the live image.
627 (target-esp (if (file-exists? (string-append mount-point efi-dir))
628 (string-append mount-point efi-dir)
629 efi-dir)))
630 ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or
631 ;; root partition.
632 (setenv "GRUB_ENABLE_CRYPTODISK" "y")
633 (invoke/quiet grub-install "--boot-directory" install-dir
634 "--removable"
635 ;; "--no-nvram"
636 "--bootloader-id=Guix"
637 "--efi-directory" target-esp)))))
638
611(define (install-grub-efi-netboot subdir) 639(define (install-grub-efi-netboot subdir)
612 "Define a grub-efi-netboot bootloader installer for installation in SUBDIR, 640 "Define a grub-efi-netboot bootloader installer for installation in SUBDIR,
613which is usually efi/Guix or efi/boot." 641which is usually efi/Guix or efi/boot."
@@ -734,6 +762,12 @@ considered for security aspects."
734 (name 'grub-efi) 762 (name 'grub-efi)
735 (package grub-efi))) 763 (package grub-efi)))
736 764
765(define grub-efi-removable-bootloader
766 (bootloader
767 (inherit grub-efi-bootloader)
768 (name 'grub-efi-removable-bootloader)
769 (installer install-grub-efi-removable)))
770
737(define grub-efi-netboot-bootloader 771(define grub-efi-netboot-bootloader
738 (bootloader 772 (bootloader
739 (inherit grub-efi-bootloader) 773 (inherit grub-efi-bootloader)