# The install medium's console: what the docs say (card t_1cf58a28)

Read 2026-11-05 before changing anything.  Sources are in the tree.

## installboot(8): the option that fixes the console

src/usr.sbin/installboot/installboot.8:363-367

    .It Ic console Ns Li = Ns Ar name
    .Sy [ amd64 ,
    .Sy i386 ]
    Set the console device.
    .Ar name
    must be one of:
    .Ic pc ,
    ...

and the example at src/usr.sbin/installboot/installboot.8:953-959:

    with an ISO 9660 file system for an i386 system with a serial console:

        installboot -o console=com0,speed=19200 -m i386 -e bootxx

## The existing pattern in this tree: bootcd-com

src/distrib/amd64/cdroms/bootcd-com/Makefile:7-8

    # HP Proliant iLO serial console is on com1
    CDBOOTOPTIONS=	-o console=com0

src/distrib/amd64/cdroms/Makefile.cdrom:47-52 applies it to the EFI boot image:

    .for file in ${CDSETS_EXCLUDE}
        ${RM} -f cdrom/${file}
    .endfor
    ...
        ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} efiboot/EFI/boot/bootx64.efi

So the loader starts on com0 and passes com0 to the kernel; that is why
boot-com.iso's kernel prints on the serial line and the installcd's does not.

## The module warning on that line is not the medium

src/sys/lib/libsa/cd9660.c:284 sets fsmod = "cd9660" whenever the loader opens
a CD, and src/sys/arch/i386/stand/lib/exec.c's module_init() counts every
module entry it cannot open in nfail:

    if (fd == -1) { bm->bm_len = -1; ++nfail; continue; }

The boot.cfg the medium actually carries is src/etc/etc.amd64/boot.cfg (the etc
set is extracted after the generated boot.cfg, see
patches/src/0007-boot-cfg-timeout-5s.patch:11-18), and its first menu line is

    menu=Boot normally:rndseed /var/db/entropy-file;boot

The medium has no /var/db/entropy-file, so that rndseed entry is the one that
fails; the log prints "WARNING: couldn't open /var/db/entropy-file"
immediately before the count.  Measured 2026-11-05 with the same medium booted
at the loader prompt with `modules off`: the kernel still reports
`root file system type: cd9660` and starts /bin/sh, i.e. cd9660 is compiled
into GENERIC and the preloaded module is not what makes the CD readable.

## What the cgd root needs on an EFI disk (the tree's own layout)

src/usr.sbin/sysinst/arch/i386/md.c:499-700, setup_cgd_boot(), writes the boot
files to the EFI system partition (mounted msdos):

  - EFI/NetBSD/boot.cfg with
        menu=Boot encrypted NetBSD:fs /ramdisk-cgdroot.fs;boot /netbsd
        timeout=10
        consdev=com<N>[,<speed>]     (when the install ran on serial)
  - /netbsd, /ramdisk-cgdroot.fs, /cgdroot (cgdconfig parameters)
  - /cgd.conf with  "cgd<N> <partition> /etc/cgd/cgdroot"

and src/distrib/common/cgdroot.rc:39-85 mounts that partition at /etc/cgd with
mount_msdos -l, so /cgd.conf comes back as /etc/cgd/cgd.conf and /cgdroot as
/etc/cgd/cgdroot, then runs cgdconfig -C.

Note: efiboot has no consdev command of its own (src/sys/stand/efiboot/boot.c's
command table), but libsa/bootcfg.c:226-227 parses the key; the BIOS boot2.c
applies it.  Under OVMF the EFI loader's own console is already com0, so the
kernel inherits it without the key.

## Measured 2026-11-05, after the change (build/logs/fde-manual.log)

- make release ARCH=amd64 exit 0 (13:43-13:51), but it does NOT write
  RELEASEDIR/images: for CDRELEASE=true the release target in
  distrib/common/Makefile.bootcd:341-352 is empty and iso_image builds the
  image.  `make iso ARCH=amd64` (13:55-13:57) wrote
  build/obj/releasedir/images/NetBSD-11.99.9-amd64.iso (731070464 bytes).
- mtimes inside that ISO: /netbsd Nov 5 13:56, cd9660.kmod Nov 2 23:29.  The
  module is not rebuilt because its source did not change; the loader warning
  is not caused by that difference (same module on boot-com.iso mounts
  cd9660, and with `modules off` at the loader prompt the same kernel reports
  "root file system type: cd9660" and starts /bin/sh).
- loader console: with the CDBOOTOPTIONS line the BIOS loader and the kernel
  both print on com0; the serial line carries the menu, the countdown, the
  single-user prompt and every command of the install
  (fde-manual.log: "single user shell").
- the EFI loader's menu does not take keys from the qemu serial socket under
  OVMF (measured: the countdown ran out with SPACE bytes already queued), so a
  serial-driven install boots the medium under SeaBIOS, where the loader takes
  them (same loop as tools/fde-boot-installer.seq: keep sending SPACE until
  "Option: [1]:" answers, then "2\n").
- newfs(8) on the cgd device needs -I: without it, "newfs: /dev/rcgd0 partition
  type is not `4.2BSD'" (sbin/newfs/newfs.c:571-580; the cgd device has no
  label saying 4.2BSD).
- the installed /dev needs MAKEDEV all: without it rc(8) stops with
  "cannot create /dev/null: read-only file system" and never reaches getty.
- phase 2, the installed disk under OVMF: the ATA disk sat in the firmware's
  boot manager with no serial output.  As removable USB storage
  (-device usb-storage,removable=on) OVMF takes its default
  \EFI\BOOT\BOOTX64.EFI path and boots the ESP.  The loader then names that
  partition hd0a: "boot /netbsd" resolved to hd0b and failed with
  "open /netbsd: No such file or directory", while
  "boot hd0a:/netbsd" plus "fs hd0a:/ramdisk-cgdroot.fs" loads kernel and
  ramdisk.
- result: /dev/dk1's passphrase: -> init.root: / -> /altroot -> rc(8) ->
  "NetBSD/amd64 (Amnesiac) (constty)" and "login:" (fde-manual.log last line).
