summaryrefslogtreecommitdiff
path: root/gnu/services/base.scm
diff options
context:
space:
mode:
authorRutherther <rutherther@ditigal.xyz>2026-01-03 15:36:00 +0100
committerRutherther <rutherther@ditigal.xyz>2026-01-14 09:17:33 +0100
commitab22501915fa57cf3a3f94dcc7fec86b433d85ad (patch)
tree5008e84b52279284d7467ae78cc78b569a89e850 /gnu/services/base.scm
parent84a018b3569a26fbb99d0c71fdbd2addb5686467 (diff)
install: Register agetty on primary console on AArch64.
This adds the possibility to parse /proc/consoles to find a primary console. Then, on AArch64 this is used in the installation image. On AArch64, the boot usually happens with chosen device tree that contains the serial console. On x86_64, this does not happen so often, so we keep the installation iso minimal there. The primary console is chosen, but there is a fallback to any non-virtual one. Virtual console (/dev/tty0) is skipped, because that one can point to any console, like /dev/tty1 and so on. So it's not safe to register agetty on it. * gnu/build/linux-boot.scm (read-linux-consoles): New variable. * gnu/services/base.scm (default-serial-console): Use primary console as fallback. * gnu/system/install.scm (%installation-services): Add agetty tty for consoles. Change-Id: Iae01f7bc85b5ffdef2e52b1d0710889915b0f54a Signed-off-by: Rutherther <rutherther@ditigal.xyz>
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r--gnu/services/base.scm21
1 files changed, 19 insertions, 2 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 4a4f1d17c18..850b651b9a3 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -1060,6 +1060,9 @@ to use as the tty. This is primarily useful for headless systems."
(with-imported-modules (source-module-closure
'((gnu build linux-boot))) ;for 'find-long-options'
#~(begin
+ (use-modules (gnu build linux-boot)
+ (srfi srfi-1))
+
;; console=device,options
;; device: can be tty0, ttyS0, lp0, ttyUSB0 (serial).
;; options: BBBBPNF. P n|o|e, N number of bits,
@@ -1083,7 +1086,20 @@ to use as the tty. This is primarily useful for headless systems."
(find-long-options "console" command)))
(specs (append agetty-specs console-specs)))
(match specs
- (() #f)
+ ;; Fallback to a physical console registered in /proc/consoles.
+ (() (let* ((consoles (read-linux-consoles))
+ (chosen-console
+ ;; Prioritize preferred, if none, choose any enabled.
+ (or (find (lambda (c)
+ (and (not (linux-console-virtual? c))
+ (linux-console-preferred? c)))
+ consoles)
+ (find (lambda (c)
+ (and (not (linux-console-virtual? c))
+ (linux-console-enabled? c)))
+ consoles))))
+ (and chosen-console
+ (linux-console-device chosen-console))))
((spec _ ...)
;; Extract device name from first spec.
(match (string-tokenize spec not-comma)
@@ -1111,7 +1127,8 @@ to use as the tty. This is primarily useful for headless systems."
(requirement (cons* 'user-processes 'host-name 'udev
shepherd-requirement))
- (modules '((ice-9 match) (gnu build linux-boot)))
+ (modules '((ice-9 match) (gnu build linux-boot)
+ (srfi srfi-1)))
(start
(with-imported-modules (source-module-closure
'((gnu build linux-boot)))