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.
This commit is contained in:
Mathieu Othacehe 2021-12-27 19:12:54 +01:00
parent 5c5d9e5a32
commit c6910baf36
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 38 additions and 16 deletions

View file

@ -83,7 +83,8 @@ (define (device-items)
devices)) devices))
(let* ((result (run-listbox-selection-page (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") #:title (G_ "Disk")
#:listbox-items (device-items) #:listbox-items (device-items)
#:listbox-item->text cdr #:listbox-item->text cdr
@ -792,13 +793,13 @@ (define (run-page devices)
result-user-partitions))))) result-user-partitions)))))
(init-parted) (init-parted)
(let* ((non-install-devices (non-install-devices)) (let* ((eligible-devices (eligible-devices))
(user-partitions (run-page non-install-devices)) (user-partitions (run-page eligible-devices))
(user-partitions-with-pass (prompt-luks-passwords (user-partitions-with-pass (prompt-luks-passwords
user-partitions)) user-partitions))
(form (draw-formatting-page user-partitions))) (form (draw-formatting-page user-partitions)))
;; Make sure the disks are not in use before proceeding to formatting. ;; 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) (format-user-partitions user-partitions-with-pass)
(syslog "formatted ~a user partitions~%" (syslog "formatted ~a user partitions~%"
(length user-partitions-with-pass)) (length user-partitions-with-pass))

View file

@ -81,7 +81,7 @@ (define-module (gnu installer parted)
with-delay-device-in-use? with-delay-device-in-use?
force-device-sync force-device-sync
non-install-devices eligible-devices
partition-user-type partition-user-type
user-fs-type-name user-fs-type-name
partition-filesystem-user-type partition-filesystem-user-type
@ -356,28 +356,49 @@ (define (installer-root-partition-path)
(and=> (uuid root) (and=> (uuid root)
find-partition-by-uuid))))) find-partition-by-uuid)))))
(define (non-install-devices) ;; Minimal installation device size.
"Return all the available devices, except the install device." (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 (define the-installer-root-partition-path
(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 ;; Read partition table of device and compare each path to the one
;; we're booting from to determine if it is the installation ;; we're booting from to determine if it is the installation
;; device. ;; device.
(define (installation-device? device) (define (installation-device? device)
;; When using CDROM based installation, the root partition path may be the ;; When using CDROM based installation, the root partition path may be the
;; device path. ;; device path.
(or (string=? the-installer-root-partition-path (and (or (string=? the-installer-root-partition-path
(device-path device)) (device-path device))
(let ((disk (disk-new device))) (let ((disk (disk-new device)))
(and disk (and disk
(any (lambda (partition) (any (lambda (partition)
(string=? the-installer-root-partition-path (string=? the-installer-root-partition-path
(partition-get-path partition))) (partition-get-path partition)))
(disk-partitions disk)))))) (disk-partitions disk)))))
(syslog "~a is not eligible because it is the installation device.~%"
(device-path device))))
(remove installation-device? (devices))) (remove
(lambda (device)
(or (installation-device? device)
(small-device? device)))
(devices)))
;; ;;