From patchwork Tue Aug 1 21:09:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomas Volf X-Patchwork-Id: 52455 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 03FB527BBEA; Tue, 1 Aug 2023 22:10:18 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=no 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 060CA27BBE2 for ; Tue, 1 Aug 2023 22:10:17 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQwd2-00084m-HU; Tue, 01 Aug 2023 17:10:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQwd0-00084c-Cu for guix-patches@gnu.org; Tue, 01 Aug 2023 17:10:02 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQwcz-0005RM-Ut for guix-patches@gnu.org; Tue, 01 Aug 2023 17:10:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qQwcz-0002IB-Q8 for guix-patches@gnu.org; Tue, 01 Aug 2023 17:10:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65002] [PATCH 1/2] mapped-devices: Allow unlocking by a key file Resent-From: Tomas Volf Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 01 Aug 2023 21:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65002 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65002@debbugs.gnu.org Cc: Tomas Volf Received: via spool by 65002-submit@debbugs.gnu.org id=B65002.16909241758766 (code B ref 65002); Tue, 01 Aug 2023 21:10:01 +0000 Received: (at 65002) by debbugs.gnu.org; 1 Aug 2023 21:09:35 +0000 Received: from localhost ([127.0.0.1]:48395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQwcY-0002HI-Cc for submit@debbugs.gnu.org; Tue, 01 Aug 2023 17:09:34 -0400 Received: from wolfsden.cz ([37.205.8.62]:38938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQwcV-0002H3-9g for 65002@debbugs.gnu.org; Tue, 01 Aug 2023 17:09:32 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 263A526B500; Tue, 1 Aug 2023 21:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1690924170; bh=kFmjcpSbdWQtl9UmFxfPohQbZUZvY8Voscpvjffn5k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZPMEYHnnHaWeBs7J7a+WU4CAyBwU7j6jW2GvEGtKWsNd6oUHKbWed+hKOz9xhJO3l mUZQYsAG8F0s9pGsp1lN2VT9FWeCVWN3LYS3Ga4ENz1tVu2A8p50XLwg+8hAueCD8Z St+tE/q9XkW5Lrx3acVE4VLDU+VS9TGrCV/+/UthP5Sj1F/AzcAN9/eSYRlnPlrCqV Cdlm1b1vsF/wbPWbpVvroGv1wK0veYpWPj1aHO6/IBpWw6PAbK/YiXW0w0axPw5aMN n6JFIGYH6bKD2gKMNqLFjKiUpxNCc0PonvqAKkeigCwcD6gobzK9INIJK+dBe5mhvL F0OJ8f/Itxi3wSeV/2f2HQsDBPNDhuoDZid+K9zDa0aR6wJgJocYfteqYKetwUu070 7gqIdmw/GBlAb3HFnQq073CtlLJls0Ze8dsJ41EVFQ3Ye5bhsZHY0HDCTdMcvJdbey C3gfPeCqVlt9VWOB+AriBNIAfmFr9Vp+ZCm91Wo1+grF1yjvHc+Ao2Oqc7OeqnQ8Ob NtuKHsN8FtbP7L2ld/YDQWobiAjqpeVMAydq9mF2NWfy5Yqgfe7CtRkv8lwNcMGpVC obyztcOJ9cvKLbq31AQpT9i9UPVSNZaehntvTHnY1183t0FD1ZaFiSHdjpMGhJbFoo WaKMkp4t5zAiEiXaxPF5JlVQ= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 9B61726A843; Tue, 1 Aug 2023 21:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1690924169; bh=kFmjcpSbdWQtl9UmFxfPohQbZUZvY8Voscpvjffn5k8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mp8S8RLeG6DguhNuGas5OuJZbf4alGv9Edug/6j8VHfSV5wqo2itwMuUeV/PfB1l4 FFfZWjaH/loBvhWy1UMldMaJqqTodg2iJhbkwMMEA3fyG0c4JJXChYOLdY9kbRzRjc b0b7lrsfscpye284RvP8+4HctEzuo+7Y9HjeMLviJSsXX8R7QVG8hGkOG0ko15DhPu 5x1NrHtc4ue0ZZmJ5ohuEBaR82JN9X/qcoHlga1RwM/cL8fE0Df7liILVFUQljHvM7 q25dzQLlK1Hml2LgoJBvr3ByNz0bCUHdVeGkl4/O6Cak4MXoWbLxTQzaxz5DVUSnpP CGUU2kSWG8lc5n4r0qYTYVYcDjK8iR42epOvI/0h6w3S7D+/vDSBv1KJWOU3RnP/gT LziGgFzjJk30iIOEexi8Z0Oa2TFFJs3V9BwxsalH2tBsW77V+cDvb5xcmsZcUnDdmn 9ozwdLeErM3IFSVFINIO41vKpIIvHym0RMVLtbNuT+cwL43irT79oYtayqSGYBtFom XFI0+hG/+3SEU3TuYszwBB1tl0ld869o0gSFcojxPV4BO49N+GLBxM38CBwFaJ//VH GXaK7P+VIi4yNPOB2QfhoeJ0zLvy0k9Jo42Qy5hqSQt48QY7X3PFOqRUx/7Id5KHp5 QnhwNRPbK6+BkO4+Zi0QVulw= Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id accfd339; Tue, 1 Aug 2023 21:09:29 +0000 (UTC) From: Tomas Volf Date: Tue, 1 Aug 2023 23:09:20 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Requiring the user to input their password in order to unlock a device is not always reasonable, so having an option to unlock the device using a key file is a nice quality of life change. * gnu/system/mapped-devices.scm (luks-device-mapping): New keyword argument * gnu/system/mapped-devices.scm (luks-device-mapping-with-options): New procedure --- doc/guix.texi | 12 +++++++ gnu/system/mapped-devices.scm | 67 ++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 58cc3d7aad..a857654191 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17622,6 +17622,18 @@ Mapped Devices @code{dm-crypt} Linux kernel module. @end defvar +@deffn {Procedure} luks-device-mapping-with-options [#:key-file] +Return a @code{luks-device-mapping} object, which defines LUKS block +device encryption using the @command{cryptsetup} command from the +package with the same name. It relies on the @code{dm-crypt} Linux +kernel module. + +If @code{key-file} is provided, unlocking is first attempted using that +key file. If it fails, password unlock is attempted as well. Key file +is not stored in the store and needs to be available at the specified +path at the time of the unlock attempt. +@end deffn + @defvar raid-device-mapping This defines a RAID device, which is assembled using the @code{mdadm} command from the package with the same name. It requires a Linux kernel diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index e6b8970c12..79b776e81e 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014-2022 Ludovic Courtès ;;; Copyright © 2016 Andreas Enge ;;; Copyright © 2017, 2018 Mark H Weaver +;;; Copyright © 2023 Tomas Volf ;;; ;;; This file is part of GNU Guix. ;;; @@ -64,6 +65,7 @@ (define-module (gnu system mapped-devices) check-device-initrd-modules ;XXX: needs a better place luks-device-mapping + luks-device-mapping-with-options raid-device-mapping lvm-device-mapping)) @@ -188,7 +190,7 @@ (define (check-device-initrd-modules device linux-modules location) ;;; Common device mappings. ;;; -(define (open-luks-device source targets) +(define* (open-luks-device source targets #:key key-file) "Return a gexp that maps SOURCE to TARGET as a LUKS device, using 'cryptsetup'." (with-imported-modules (source-module-closure @@ -198,7 +200,8 @@ (define (open-luks-device source targets) ((target) #~(let ((source #$(if (uuid? source) (uuid-bytevector source) - source))) + source)) + (keyfile #$key-file)) ;; XXX: 'use-modules' should be at the top level. (use-modules (rnrs bytevectors) ;bytevector? ((gnu build file-systems) @@ -215,29 +218,35 @@ (define (open-luks-device source targets) ;; 'cryptsetup open' requires standard input to be a tty to allow ;; for interaction but shepherd sets standard input to /dev/null; ;; thus, explicitly request a tty. - (zero? (system*/tty - #$(file-append cryptsetup-static "/sbin/cryptsetup") - "open" "--type" "luks" - - ;; Note: We cannot use the "UUID=source" syntax here - ;; because 'cryptsetup' implements it by searching the - ;; udev-populated /dev/disk/by-id directory but udev may - ;; be unavailable at the time we run this. - (if (bytevector? source) - (or (let loop ((tries-left 10)) - (and (positive? tries-left) - (or (find-partition-by-luks-uuid source) - ;; If the underlying partition is - ;; not found, try again after - ;; waiting a second, up to ten - ;; times. FIXME: This should be - ;; dealt with in a more robust way. - (begin (sleep 1) - (loop (- tries-left 1)))))) - (error "LUKS partition not found" source)) - source) - - #$target))))))) + (let ((partition + ;; Note: We cannot use the "UUID=source" syntax here + ;; because 'cryptsetup' implements it by searching the + ;; udev-populated /dev/disk/by-id directory but udev may + ;; be unavailable at the time we run this. + (if (bytevector? source) + (or (let loop ((tries-left 10)) + (and (positive? tries-left) + (or (find-partition-by-luks-uuid source) + ;; If the underlying partition is + ;; not found, try again after + ;; waiting a second, up to ten + ;; times. FIXME: This should be + ;; dealt with in a more robust way. + (begin (sleep 1) + (loop (- tries-left 1)))))) + (error "LUKS partition not found" source)) + source))) + ;; We want to fallback to the password unlock if the keyfile fails. + (or (and keyfile + (zero? (system*/tty + #$(file-append cryptsetup-static "/sbin/cryptsetup") + "open" "--type" "luks" + "--key-file" keyfile + partition #$target))) + (zero? (system*/tty + #$(file-append cryptsetup-static "/sbin/cryptsetup") + "open" "--type" "luks" + partition #$target))))))))) (define (close-luks-device source targets) "Return a gexp that closes TARGET, a LUKS device." @@ -276,6 +285,14 @@ (define luks-device-mapping (close close-luks-device) (check check-luks-device))) +(define* (luks-device-mapping-with-options #:key key-file) + "Return a luks-device-mapping object with open modified to pass the arguments +into the open-luks-device procedure." + (mapped-device-kind + (inherit luks-device-mapping) + (open (λ (source targets) (open-luks-device source targets + #:key-file key-file))))) + (define (open-raid-device sources targets) "Return a gexp that assembles SOURCES (a list of devices) to the RAID device TARGET (e.g., \"/dev/md0\"), using 'mdadm'." From patchwork Tue Aug 1 21:09:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Volf X-Patchwork-Id: 52454 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 4B37427BBEB; Tue, 1 Aug 2023 22:10:15 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=no 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 1C2E727BBE2 for ; Tue, 1 Aug 2023 22:10:14 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQwd3-000879-Hg; Tue, 01 Aug 2023 17:10:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQwd2-00084l-2g for guix-patches@gnu.org; Tue, 01 Aug 2023 17:10:04 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQwd0-0005Rt-AI for guix-patches@gnu.org; Tue, 01 Aug 2023 17:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qQwd0-0002II-5x for guix-patches@gnu.org; Tue, 01 Aug 2023 17:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65002] [PATCH 2/2] gnu: bootloader: grub: Add support for loading an additional initrd Resent-From: Tomas Volf Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 01 Aug 2023 21:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65002 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65002@debbugs.gnu.org Cc: Tomas Volf Received: via spool by 65002-submit@debbugs.gnu.org id=B65002.16909241758772 (code B ref 65002); Tue, 01 Aug 2023 21:10:02 +0000 Received: (at 65002) by debbugs.gnu.org; 1 Aug 2023 21:09:35 +0000 Received: from localhost ([127.0.0.1]:48397 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQwcY-0002HL-Uw for submit@debbugs.gnu.org; Tue, 01 Aug 2023 17:09:35 -0400 Received: from wolfsden.cz ([37.205.8.62]:38950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qQwcV-0002H5-Nn for 65002@debbugs.gnu.org; Tue, 01 Aug 2023 17:09:33 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 26B762681E5; Tue, 1 Aug 2023 21:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1690924171; bh=H3o4VWBJFRBDCTPIn9sdJRunY6hUg3BcfyGOtH+x/B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lggRhuZneq4k0f2kLKJr39FOxF1BBztT4WPbpIDjRkJ5i9VvPwZNBZttQ7W7cMY3N lrOotfM65cDVRmVdw+9DrZmU6p1XLD8JdOSIAdcUH7AuhiZPt9KxVWL1PMfOFalNqM KB6RZHvmcB7zJdVJbGx363IaK3vvnq4OYqJ7UnhyeranZwHz7FOTFRU+zbfDbo7cSd S8wPicQMQDsZr55PGLdL0F+Pg/GuQFw0ZEph/8ctAgLyMaMYTvToNIsexFfaL2GHJg VTRLx6KZ6yjagU956rUYfORBnC4Oh9yDtNeh+eYqgsi9qmQnz7aK0vd6jj7fsrBru7 UNMfdv1dQ8bFUCuR0j65DourLSdIYft9wwjyZqlKHGZDcvmTY3+RnJOvZlthDEjkLw ICK1twET+75AbW6L2d7pwDjynpOAVvkdRsQDnA9YX89d/36KzJhg5eSJf+yuXVzqbg eF6kXp+TdRV49XHOsmCko9dRjyREdVUXZIkNms7qXk21shxrQgQtVecWuA6dPa7DMl YriM7Tk0OHmi1nPH8lFmsYVEGR/W1hv0W+kXn7qHmcX0MCauAyFYV5BBSOAz7k16s4 n0AEkZLCEAh8K70HypDDjG2AIS7UV4CqpA8rEREniV4HR+J4D+n4I8zzjPioAMtwIt MHbmn2xQwqVuJHMnWdqFflk4= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id B46BF26985C; Tue, 1 Aug 2023 21:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1690924170; bh=H3o4VWBJFRBDCTPIn9sdJRunY6hUg3BcfyGOtH+x/B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PaQGJcKiT5ujHs1Bc7ZcyN2d0ZY+hdsFH+j+qG1M1DCMYf6Nl9RZwZILuVkYHyUUD mZeZgHz4asjofB3gwf9XzQvVs5N9kpRfqutImhyv2Ps5NobyfK7JzMOtb0FQyayVhI I/VzNkPxONfpN+G4Op+j0S6Qw/mjdPvQIZ8kxXNeZyedo/BGsn0RWR9f7ELvqP4N9J fvVjsKgMzsdL+6VjPEfm2nOjDsRG7EVi6+vDEvXOKVg6lr0LXGcQsmUZiMjjEJtwSo ufx3BFX5YnzB4P/vU2FDR5CX3Z+ILPHtGRiI15xmDKv5DVDZGGehJig+qo/1U6IgRE A7Qm86fMfEVvmVAYzFG2uW9ouV/dVM10K62ZNdXYiTFNlYJu0wNgOUVZm/kttcQTn+ Jse6qN2T5GAY1aBSFZdFkKDInWRjfiqJ+RDgmT52NbNenvZdM9eupi9JFlYtH6AAXH FVbsUynwYaN5+b7hn15Y7mZk+J33IGcXTbh8Ftdbco/ot0LRKhDs/3Ho77G02LVKQO 00XhpGKvYFwiyERslKXLILLentNVY7YcrPLRSybC8Yxz1O+lKKDq9Y8QtIgqJP5VgL WXo39ZroElWIxwrFfgqRpMwYllrSGVdvKCt4oOPAdO51PqXyKdLd0xbcUfs+LFBLpR GImEg2euMezf1oYwBzWfAt6E= Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id e84ebce9; Tue, 1 Aug 2023 21:09:30 +0000 (UTC) From: Tomas Volf Date: Tue, 1 Aug 2023 23:09:21 +0200 Message-ID: <01792b1d4bf827da9d10b4f06cfe9127b9cfbe45.1690922760.git.wolf@wolfsden.cz> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches In order to be able to provide decryption keys for the LUKS device, they need to be available in the initial ram disk. However they cannot be stored inside the usual initrd, since it is stored in the store and being a world-readable (as files in the store are) is not a desired property for a initrd containing decryption keys. This commit adds an option to load additional initrd during the boot, one that is not stored inside the store and therefore can contain secrets. Since only grub supports encrypted /boot, only grub is modified to use the extra-initrd. There is no use case for the other bootloaders. * doc/guix.texi (Bootloader Configuration): Describe the new extra-initrd field. * gnu/bootloader.scm: Add extra-initrd field to bootloader-configuration * gnu/bootloader/grub.scm: Use the new extra-initrd field --- doc/guix.texi | 20 ++++++++++++++++++++ gnu/bootloader.scm | 6 +++++- gnu/bootloader/grub.scm | 6 ++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index a857654191..c63f28786e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40078,6 +40078,26 @@ Bootloader Configuration @code{u-boot} bootloader, where the device tree has already been loaded in RAM, it can be handy to disable the option by setting it to @code{#f}. + +@item @code{extra-initrd} (default: @code{#f}) +Path to an additional initrd to load. Should not point to a file in the +store. Typical use case is making keys to unlock LUKS device available +during the boot process. For any use case not involving secrets, you +should use regular initrd (@pxref{operating-system Reference, +@code{initrd}}) instead. + +Suitable image can be created for example like this: + +@example +echo /key-file.bin | cpio -oH newc >/key-file.cpio +chmod 0000 /key-file.cpio +@end example + +Be careful when using this option, since pointing to a file that is not +readable by the grub while booting will cause the boot to fail and +require a manual edit of the initrd line in the grub menu. + +Currently only supported by grub. @end table @end deftp diff --git a/gnu/bootloader.scm b/gnu/bootloader.scm index 2c36d8c6cf..8cebcf8965 100644 --- a/gnu/bootloader.scm +++ b/gnu/bootloader.scm @@ -77,6 +77,7 @@ (define-module (gnu bootloader) bootloader-configuration-serial-unit bootloader-configuration-serial-speed bootloader-configuration-device-tree-support? + bootloader-configuration-extra-initrd %bootloaders lookup-bootloader-by-name @@ -279,7 +280,10 @@ (define-record-type* (serial-speed bootloader-configuration-serial-speed (default #f)) ;integer | #f (device-tree-support? bootloader-configuration-device-tree-support? - (default #t))) ;boolean + (default #t)) ;boolean + (extra-initrd bootloader-configuration-extra-initrd + (default #f)) ;string | #f + ) (define-deprecated (bootloader-configuration-target config) bootloader-configuration-targets diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 5f3fcd7074..49cb3f7725 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -386,7 +386,8 @@ (define* (make-grub-configuration grub config entries store-directory-prefix)) (initrd (normalize-file (menu-entry-initrd entry) device-mount-point - store-directory-prefix))) + store-directory-prefix)) + (extra-initrd (bootloader-configuration-extra-initrd config))) ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. ;; Use the right file names for LINUX and INITRD in case ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a @@ -397,11 +398,12 @@ (define* (make-grub-configuration grub config entries #~(format port "menuentry ~s { ~a linux ~a ~a - initrd ~a + initrd ~a ~a }~%" #$label #$(grub-root-search device linux) #$linux (string-join (list #$@arguments)) + (or #$extra-initrd "") #$initrd))) (multiboot-kernel (let* ((kernel (menu-entry-multiboot-kernel entry))