From patchwork Sat Oct 30 16:12:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 34172 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 B61CF27BBE3; Sat, 30 Oct 2021 17:13:24 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8350E27BBE1 for ; Sat, 30 Oct 2021 17:13:24 +0100 (BST) Received: from localhost ([::1]:41520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgqyx-0003uf-H3 for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 12:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgqyc-0003uG-RW for guix-patches@gnu.org; Sat, 30 Oct 2021 12:13:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgqyc-0007Ng-JB for guix-patches@gnu.org; Sat, 30 Oct 2021 12:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgqyc-0002Tf-EA for guix-patches@gnu.org; Sat, 30 Oct 2021 12:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51514] [PATCH 1/2] gnu: system: Add LUKS2 support for the root file system. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 16:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51514 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51514@debbugs.gnu.org Cc: Josselin Poiret Received: via spool by 51514-submit@debbugs.gnu.org id=B51514.16356103809515 (code B ref 51514); Sat, 30 Oct 2021 16:13:02 +0000 Received: (at 51514) by debbugs.gnu.org; 30 Oct 2021 16:13:00 +0000 Received: from localhost ([127.0.0.1]:58275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgqya-0002TP-E5 for submit@debbugs.gnu.org; Sat, 30 Oct 2021 12:13:00 -0400 Received: from jpoiret.xyz ([206.189.101.64]:38042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgqyY-0002TF-4d for 51514@debbugs.gnu.org; Sat, 30 Oct 2021 12:12:58 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id A091C184D63; Sat, 30 Oct 2021 16:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1635610377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Zv9Gcr1iv3oUQ6N1bzyDp8YYn0niE8dMNIOqrBcRmQ=; b=Jh6T7ZyYOdL24GusoYojrMvdu6dx+F8Wn7nCwYKzOmOXcqhJV03r7TWLMb6zCPHakjMRYE TFjdu8TIsTUuGdeeRQRa1PMW2JhjOo06ZcBrA42gMX8Cyqb763WVcaRFFB+UQtq8qbabIy ePUPO+6L9fMOulJFapUywUKbkF4F3ZANvn+1VW5TGtKtfwI+EY/EpDRaDoPSYwrAILJBMF y4Nu8ykJPQx0f7hER4PTWfFxNLFKs+ZOpJ06Se9Y5I8VRRPVy1eQ9qf71wDDjYx744i6OW k65IAywz1k0UDY1q/KDyFokmeMe3+JPKF/yC8xBC8HJsnt1Py8Qsy/oi81ijLA== Date: Sat, 30 Oct 2021 16:12:36 +0000 Message-Id: <20211030161237.28298-1-dev@jpoiret.xyz> In-Reply-To: <87tugypkum.fsf@jpoiret.xyz> References: <87tugypkum.fsf@jpoiret.xyz> MIME-Version: 1.0 X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz 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" Reply-to: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches * gnu/bootloader/grub.scm (grub-configuration-file): Add 'insmod luks2'. * gnu/system/mapped-devices.scm (open-luks-device): Create '/run/cryptsetup/' directory. --- gnu/bootloader/grub.scm | 3 +-- gnu/system/mapped-devices.scm | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index d8e888ff40..42f71aa4db 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -415,8 +415,7 @@ (define (crypto-device->cryptomount dev) ;; Other type of devices aren't implemented. #~())) (let ((devices (map crypto-device->cryptomount store-crypto-devices)) - ;; XXX: Add luks2 when grub 2.06 is packaged. - (modules #~(format port "insmod luks~%"))) + (modules #~(format port "insmod luks~%insmod luks2~%"))) (if (null? devices) devices (cons modules devices)))) diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 518dbc4fe8..95944b03c8 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -192,7 +192,8 @@ (define (open-luks-device source targets) "Return a gexp that maps SOURCE to TARGET as a LUKS device, using 'cryptsetup'." (with-imported-modules (source-module-closure - '((gnu build file-systems))) + '((gnu build file-systems) + (guix build utils))) ;; For mkdir-p (match targets ((target) #~(let ((source #$(if (uuid? source) @@ -201,7 +202,12 @@ (define (open-luks-device source targets) ;; XXX: 'use-modules' should be at the top level. (use-modules (rnrs bytevectors) ;bytevector? ((gnu build file-systems) - #:select (find-partition-by-luks-uuid))) + #:select (find-partition-by-luks-uuid)) + ((guix build utils) #:select (mkdir-p))) + + ;; Create '/run/cryptsetup/' if it does not exist, as device locking + ;; is mandatory for LUKS2. + (mkdir-p "/run/cryptsetup/") ;; Use 'cryptsetup-static', not 'cryptsetup', to avoid pulling the ;; whole world inside the initrd (for when we're in an initrd). From patchwork Sat Oct 30 16:12:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 34173 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 94E2827BBE3; Sat, 30 Oct 2021 17:16:44 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6188127BBE1 for ; Sat, 30 Oct 2021 17:16:44 +0100 (BST) Received: from localhost ([::1]:44552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgr2B-000662-GO for patchwork@mira.cbaines.net; Sat, 30 Oct 2021 12:16:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgqzb-00048h-A0 for guix-patches@gnu.org; Sat, 30 Oct 2021 12:14:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgqzZ-0000FW-Ud for guix-patches@gnu.org; Sat, 30 Oct 2021 12:14:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mgqzZ-0002Vm-QW for guix-patches@gnu.org; Sat, 30 Oct 2021 12:14:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51514] [PATCH 2/2] doc: Document LUKS2 Grub support and shortcomings Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 30 Oct 2021 16:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51514 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51514@debbugs.gnu.org Cc: Josselin Poiret Received: via spool by 51514-submit@debbugs.gnu.org id=B51514.16356103899562 (code B ref 51514); Sat, 30 Oct 2021 16:14:01 +0000 Received: (at 51514) by debbugs.gnu.org; 30 Oct 2021 16:13:09 +0000 Received: from localhost ([127.0.0.1]:58280 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgqyi-0002UA-NU for submit@debbugs.gnu.org; Sat, 30 Oct 2021 12:13:08 -0400 Received: from jpoiret.xyz ([206.189.101.64]:38114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mgqyh-0002U2-9H for 51514@debbugs.gnu.org; Sat, 30 Oct 2021 12:13:07 -0400 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 30EB1184F41; Sat, 30 Oct 2021 16:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1635610386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LljGzYt5EwyfozO9dceE8ggdtl+7SmE0+PlAT1T3Eoo=; b=Nwsjwurl6JN3fuZXyxRhzb7acO98UqoYvsFvyykpdEKXKQQ+UCLTqoqfbDrVwjCg9vSPpE 4WEsHjxjdC2r2rNCLleJtS9+9D8FWxRVOZtTp8fx1F0+rlqS8nROZYTJBpkgdCZAadhBTM ylpZcmwGXxxktYsbm6zN0+kGtNDrN5fByVRSMFfNMPHMtLiwYAcr6Lf5lz0CgF6L9OC6+U ixaw/CKbkb43k/nBqRp4DLq5aeF3K9IF/BOQnV/lhZ6YrG1fVikyT/dwnO+9Tt7cTCIsIf L+Zqirx00EGQXAql56nBIjouE1ZuCGQ2/+X4aMFYYQrkyD3vm6FScjTbMuTK8g== Date: Sat, 30 Oct 2021 16:12:37 +0000 Message-Id: <20211030161237.28298-2-dev@jpoiret.xyz> In-Reply-To: <20211030161237.28298-1-dev@jpoiret.xyz> References: <87tugypkum.fsf@jpoiret.xyz> <20211030161237.28298-1-dev@jpoiret.xyz> MIME-Version: 1.0 X-Spamd-Bar: / Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz 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" Reply-to: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches * doc/guix.texi (Keyboard Layout, Networking, and Partitioning)[Disk Partitioning]: Document it. --- doc/guix.texi | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 22215214e0..4420f67050 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -2492,13 +2492,22 @@ mkfs.ext4 -L my-root /dev/sda2 If you are instead planning to encrypt the root partition, you can use the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html, @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}}, -@code{man cryptsetup}} for more information). Assuming you want to -store the root partition on @file{/dev/sda2}, the command sequence would -be along these lines: +@code{man cryptsetup}} for more information). + +@quotation Warning +Note that Grub can unlock LUKS2 devices since version 2.06, but only +supports the PBKDF2 key derivation function, which is not the default +for Cryptsetup on Guix. You can check which key derivation function is +being used by a device by running @command{cryptsetup luksDump }, +and looking for the PBKDF field of your keyslots. +@end quotation + +Assuming you want to store the root partition on @file{/dev/sda2}, the +command sequence would be along these lines: @example -cryptsetup luksFormat /dev/sda2 -cryptsetup open --type luks /dev/sda2 my-partition +cryptsetup luksFormat --type luks2 --pbkdf pbkdf2 /dev/sda2 +cryptsetup open /dev/sda2 my-partition mkfs.ext4 -L my-root /dev/mapper/my-partition @end example