From b90504cdb5ce3d1981c8d7bc8a9cc918b0d60af7 Mon Sep 17 00:00:00 2001 From: Josselin Poiret Date: Tue, 23 Nov 2021 22:19:09 +0000 Subject: installer: Rework installation device detection. * gnu/installer/parted.scm (installation-device): Remove it. * gnu/installer/parted.scm (installer-root-partition-path): Add it. * gnu/installer/parted.scm (non-install-devices): Add installation-device? predicate. Signed-off-by: Mathieu Othacehe --- gnu/installer/parted.scm | 50 ++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'gnu/installer/parted.scm') diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index cbe676017b..ad7dd6bf91 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -26,6 +26,7 @@ #:use-module ((gnu build file-systems) #:select (canonicalize-device-spec find-partition-by-label + find-partition-by-uuid read-partition-uuid read-luks-partition-uuid)) #:use-module ((gnu build linux-boot) @@ -345,35 +346,38 @@ fail. See rereadpt function in wipefs.c of util-linux for an explanation." (with-null-output-ports (invoke "dmsetup" "remove_all"))) -(define (installation-device) - "Return the installation device path." +(define (installer-root-partition-path) + "Return the root partition path, or #f if it could not be detected." (let* ((cmdline (linux-command-line)) (root (find-long-option "--root" cmdline))) (and root - (canonicalize-device-spec (uuid root))))) + (or (and (access? root F_OK) root) + (find-partition-by-label root) + (and=> (uuid root) + find-partition-by-uuid))))) (define (non-install-devices) "Return all the available devices, except the install device." - (define (read-only? device) - (dynamic-wind - (lambda () - (device-open device)) - (lambda () - (device-read-only? device)) - (lambda () - (device-close device)))) - - ;; If parted reports that a device is read-only it is probably the - ;; installation device. However, as this detection does not always work, - ;; compare the device path to the installation device path read from the - ;; command line. - (let ((install-device (installation-device))) - (remove (lambda (device) - (let ((file-name (device-path device))) - (or (read-only? device) - (and install-device - (string=? file-name install-device))))) - (devices)))) + + (define the-installer-root-partition-path + (installer-root-partition-path)) + + ;; Read partition table of device and compare each path to the one + ;; we're booting from to determine if it is the installation + ;; device. + (define (installation-device? device) + ;; When using CDROM based installation, the root partition path may be the + ;; device path. + (or (string=? the-installer-root-partition-path + (device-path device)) + (let ((disk (disk-new device))) + (and disk + (any (lambda (partition) + (string=? the-installer-root-partition-path + (partition-get-path partition))) + (disk-partitions disk)))))) + + (remove installation-device? (devices))) ;; -- cgit 1.4.1 From a82e9f45fd9f7c67123b7064c60065281035c744 Mon Sep 17 00:00:00 2001 From: Josselin Poiret Date: Mon, 15 Nov 2021 20:53:41 +0000 Subject: installer: Make LUKS2 the default format for encrypted devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/installer/parted.scm (luks-format-and-open): Change it. Signed-off-by: Ludovic Courtès --- gnu/installer/parted.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gnu/installer/parted.scm') diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index ad7dd6bf91..616b99c3cb 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -1169,8 +1169,9 @@ USER-PARTITION if it is encrypted, or the plain file-name otherwise." (lambda (key-file) (syslog "formatting and opening LUKS entry ~s at ~s~%" label file-name) - (system* "cryptsetup" "-q" "luksFormat" file-name key-file) - (system* "cryptsetup" "open" "--type" "luks" + (system* "cryptsetup" "-q" "luksFormat" "--type" "luks2" + "--pbkdf" "pbkdf2" file-name key-file) + (system* "cryptsetup" "open" "--key-file" key-file file-name label))))) (define (luks-close user-partition) -- cgit 1.4.1 From d64b78ef0c5a8850fdd1626034a5b152a0be9bcc Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Wed, 1 Dec 2021 20:59:06 +0100 Subject: installer: parted: Use the swap-space record. * gnu/installer/parted.scm (user-partitions->configuration): Use the swap-space record. --- gnu/installer/parted.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gnu/installer/parted.scm') diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index cbe676017b..fadac36208 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -1414,9 +1414,11 @@ USER-PARTITIONS, or return nothing." (let* ((uuids (map (lambda (file) (uuid->string (read-partition-uuid file))) swap-devices))) - `((swap-devices (list ,@(map (lambda (uuid) - `(uuid ,uuid)) - uuids)))))) + `((swap-devices + (list ,@(map (lambda (uuid) + `(swap-space + (target (uuid ,uuid)))) + uuids)))))) ,@(if (null? encrypted-partitions) '() `((mapped-devices -- cgit 1.4.1 From e5e307b6768088e35be0c7526f25a3e16d93c242 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Wed, 8 Dec 2021 23:22:09 +0100 Subject: Revert "installer: Make LUKS2 the default format for encrypted devices" This reverts commit a82e9f45fd9f7c67123b7064c60065281035c744 at the author's request. We are not quite ready to boot all resulting systems. See . --- gnu/installer/parted.scm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gnu/installer/parted.scm') diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index 616b99c3cb..ad7dd6bf91 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -1169,9 +1169,8 @@ USER-PARTITION if it is encrypted, or the plain file-name otherwise." (lambda (key-file) (syslog "formatting and opening LUKS entry ~s at ~s~%" label file-name) - (system* "cryptsetup" "-q" "luksFormat" "--type" "luks2" - "--pbkdf" "pbkdf2" file-name key-file) - (system* "cryptsetup" "open" + (system* "cryptsetup" "-q" "luksFormat" file-name key-file) + (system* "cryptsetup" "open" "--type" "luks" "--key-file" key-file file-name label))))) (define (luks-close user-partition) -- cgit 1.4.1 From c6910baf361a4e7c1fbc2354875c4250452e2251 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 27 Dec 2021 19:12:54 +0100 Subject: installer: Ignore small devices. Filter the devices that are smaller than 2GiB in the device selection list. * gnu/installer/parted.scm (%min-device-size): New variable. (non-install-devices): Rename it ... (eligible-devices): ... this way. Filter the install device as well as the small devices. * gnu/installer/newt/partition.scm (run-partitioning-page): Adapt it. --- gnu/installer/newt/partition.scm | 9 ++++---- gnu/installer/parted.scm | 47 +++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 17 deletions(-) (limited to 'gnu/installer/parted.scm') diff --git a/gnu/installer/newt/partition.scm b/gnu/installer/newt/partition.scm index 70c11ed8ad..ccc7686906 100644 --- a/gnu/installer/newt/partition.scm +++ b/gnu/installer/newt/partition.scm @@ -83,7 +83,8 @@ DEVICES list." devices)) (let* ((result (run-listbox-selection-page - #:info-text (G_ "Please select a disk.") + #:info-text (G_ "Please select a \ +disk. The installation device as well as the small devices are filtered.") #:title (G_ "Disk") #:listbox-items (device-items) #:listbox-item->text cdr @@ -792,13 +793,13 @@ by pressing the Exit button.~%~%"))) result-user-partitions))))) (init-parted) - (let* ((non-install-devices (non-install-devices)) - (user-partitions (run-page non-install-devices)) + (let* ((eligible-devices (eligible-devices)) + (user-partitions (run-page eligible-devices)) (user-partitions-with-pass (prompt-luks-passwords user-partitions)) (form (draw-formatting-page user-partitions))) ;; Make sure the disks are not in use before proceeding to formatting. - (free-parted non-install-devices) + (free-parted eligible-devices) (format-user-partitions user-partitions-with-pass) (syslog "formatted ~a user partitions~%" (length user-partitions-with-pass)) diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index 289cd660fd..66e07574c9 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -81,7 +81,7 @@ with-delay-device-in-use? force-device-sync - non-install-devices + eligible-devices partition-user-type user-fs-type-name partition-filesystem-user-type @@ -356,28 +356,49 @@ fail. See rereadpt function in wipefs.c of util-linux for an explanation." (and=> (uuid root) find-partition-by-uuid))))) -(define (non-install-devices) - "Return all the available devices, except the install device." +;; Minimal installation device size. +(define %min-device-size + (* 2 GIBIBYTE-SIZE)) ;2GiB + +(define (eligible-devices) + "Return all the available devices except the install device and the devices +which are smaller than %MIN-DEVICE-SIZE." (define the-installer-root-partition-path (installer-root-partition-path)) + (define (small-device? device) + (let ((length (device-length device)) + (sector-size (device-sector-size device))) + (and (< (* length sector-size) %min-device-size) + (syslog "~a is not eligible because it is smaller than ~a.~%" + (device-path device) + (unit-format-custom-byte device + %min-device-size + UNIT-GIGABYTE))))) + ;; Read partition table of device and compare each path to the one ;; we're booting from to determine if it is the installation ;; device. (define (installation-device? device) ;; When using CDROM based installation, the root partition path may be the ;; device path. - (or (string=? the-installer-root-partition-path - (device-path device)) - (let ((disk (disk-new device))) - (and disk - (any (lambda (partition) - (string=? the-installer-root-partition-path - (partition-get-path partition))) - (disk-partitions disk)))))) - - (remove installation-device? (devices))) + (and (or (string=? the-installer-root-partition-path + (device-path device)) + (let ((disk (disk-new device))) + (and disk + (any (lambda (partition) + (string=? the-installer-root-partition-path + (partition-get-path partition))) + (disk-partitions disk))))) + (syslog "~a is not eligible because it is the installation device.~%" + (device-path device)))) + + (remove + (lambda (device) + (or (installation-device? device) + (small-device? device))) + (devices))) ;; -- cgit 1.4.1