The amd64 EFI install image remounts its root read-write and copies /tmp/gettytab into etc (distrib/amd64/installimage/etc.rc:39,46). On a read-only device the kernel accepts the remount and every write returns EIO, which is the ld0d fsbn-264208 and gettytab transcript the boot failure was reported as. Measured both ways on the medium this tree built (2026-11-04): attached writable it reaches install.sh, attached readonly=on it reproduces the card. The CD needs no writable medium -- tmpfs union on etc plus a gettytab symlink. Also corrects docs/reference/boot-cfg-timeout.txt section 9: install-image does build; those runs failed on a stale work.fstab in an object directory that is not used, because the EFI target builds inside src/.
160 lines
7.3 KiB
Plaintext
160 lines
7.3 KiB
Plaintext
The amd64 install image: what it writes into itself at boot
|
|
===========================================================
|
|
Source: the tree at /home/lotherk/src/makronix, import src/ pinned at
|
|
e523df740 (NetBSD 11.99.9), read and measured 2026-11-04.
|
|
|
|
|
|
1. The question
|
|
---------------
|
|
Card t_f56c48f0: "Install-Medium bootet nicht: cp /etc/gettytab I/O error,
|
|
ld0d write error beim Schreiben der Sets". An amd64 EFI install image, booted
|
|
under qemu/OVMF on a virtio disk, stopped with three `ld0d: error writing fsbn`
|
|
lines and `cp: /etc/gettytab: Input/output error` right after `root on dk1`.
|
|
|
|
Answer: the medium was attached read-only. The install image's own /etc/rc
|
|
remounts the root read-write and copies a file into /etc, so on a read-only
|
|
device every one of those writes must fail. Attached the way a USB stick is
|
|
attached -- writable -- the same image boots into the installer.
|
|
|
|
|
|
2. What the medium is
|
|
---------------------
|
|
src/distrib/amd64/installimage/installimage.mk:5-7
|
|
|
|
.if ${USE_XZ_SETS:Uno} != "no"
|
|
INSTIMAGEMB?= 2500 # for all installation binaries
|
|
|
|
src/distrib/amd64/installimage/Makefile:14-16 sets USE_MBR, USE_GPT and
|
|
USE_GPTMBR, so the image is a GPT disk with an EFI msdos partition and an ffs
|
|
root. Measured on the medium built from this tree (2026-11-04 23:06,
|
|
build/logs/install-image-rw-2026-11-04.log:250,301-302):
|
|
|
|
ld0: 2500 MB, 5079 cyl, 16 head, 63 sec, 512 bytes/sect x 5120000 sectors
|
|
dk0 at ld0: "EFI system", 262144 blocks at 2048, type: msdos
|
|
dk1 at ld0: "NBImgRoot", 4853760 blocks at 264192, type: ffs
|
|
|
|
and the kernel takes dk1 as root (same log, :344): `root on dk1`.
|
|
|
|
|
|
3. What its rc does -- and why a read-only medium cannot work
|
|
--------------------------------------------------------------
|
|
src/distrib/amd64/installimage/etc.rc:39-46
|
|
|
|
mount -u /
|
|
mount -t tmpfs tmpfs /tmp
|
|
|
|
# create a gettytab to autologin and run sysinst
|
|
echo "# Autostart sysinst" > /tmp/gettytab
|
|
echo -n "sysinst:al=root:lo=/install.sh:im=:sp#" >> /tmp/gettytab
|
|
stty speed >> /tmp/gettytab
|
|
cp /tmp/gettytab /etc
|
|
|
|
`mount -u /` is mount(8)'s "change the status of an already mounted file
|
|
system" (src/sbin/mount/mount.8:460-470: "a file system can be changed from
|
|
read-only to read-write or vice versa"), i.e. the root is remounted
|
|
read-write. Line 46 then writes /etc/gettytab *on the medium*.
|
|
|
|
The CD does not do this. src/distrib/amd64/cdroms/etc.rc:39-42
|
|
|
|
# mount a few tempfs to allow modifications over the CD contents
|
|
mount -t tmpfs tmpfs /tmp
|
|
mount -t tmpfs tmpfs /var
|
|
mount -t tmpfs -o union tmpfs /etc
|
|
|
|
and its /etc/gettytab is a link into /tmp, made at build time --
|
|
src/distrib/amd64/cdroms/Makefile.cdrom:54-55
|
|
|
|
${RM} -f cdrom/etc/gettytab cdrom/etc/ttys cdrom/etc/rc
|
|
${HOST_LN} -fs /tmp/gettytab cdrom/etc/gettytab
|
|
|
|
so the CD never writes to its own medium and works read-only (which is what a
|
|
CD is). The install image was written for a USB stick, which is writable, and
|
|
carries no such provision: its /etc/gettytab is a regular file from the etc
|
|
set, and the rc copies over it.
|
|
|
|
|
|
4. Measured, both ways
|
|
----------------------
|
|
Medium: build/obj/releasedir/images/NetBSD-11.99.9-amd64-install.img.gz
|
|
(built 2026-11-04 23:06 from the tree with its patches applied), decompressed
|
|
to 2621440000 bytes, attached as `-drive if=virtio,format=raw`; console moved
|
|
to com0 at the loader (`consdev com0,115200`, `boot netbsd -v`); 20 GB qcow2
|
|
target on the second virtio disk; OVMF, 4 GiB guest.
|
|
|
|
(a) attached writable (build/logs/install-image-rw-2026-11-04.log):
|
|
|
|
:344 [ 2.7737869] root on dk1
|
|
:356 Terminal type (just hit ENTER for 'vt220'):
|
|
|
|
No ld0d line, no cp error; /etc/rc reached install.sh, which is the point of
|
|
the gettytab the rc wrote. The medium boots.
|
|
|
|
The same image booted once more and driven past that one question
|
|
(build/logs/install-image-sysinst-2026-11-04.log, 0 ld0d lines):
|
|
|
|
:344 [ 2.8349162] root on dk1
|
|
:388 This menu-driven tool is designed to help you install NetBSD to a hard disk,
|
|
|
|
i.e. sysinst's main menu, reached over the serial console from the medium
|
|
this tree built today.
|
|
|
|
(b) attached `readonly=on` (build/logs/install-image-ro-2026-11-04.log):
|
|
|
|
:347 /dev/dk1: file system not clean (fs_clean=0); please fsck(8)
|
|
:348 ld0d: error writing fsbn 264208 of 264208-264211 ...
|
|
:349 ld0d: error writing fsbn 276064 of 276064-276067 ...
|
|
:350 ld0d: error writing fsbn 265792 of 265792-265823 ...
|
|
:351 cp: /etc/gettytab: Input/output error
|
|
:353+ ld0d: error writing fsbn ... every 5-10 s (22 lines in 45 s)
|
|
|
|
fsbn 264208 is block 16 of the ffs that starts at 264192: the superblock,
|
|
written by mount -u. The kernel does not refuse the remount on a device
|
|
that reports itself read-only (virtio block feature VIRTIO_BLK_F_RO is in
|
|
the feature line of both logs); it accepts it and every later write returns
|
|
EIO, which ffs then retries from the update daemon for as long as the
|
|
machine is up. The console never gets a login prompt, because getty is
|
|
started with a gettytab that was never written.
|
|
|
|
This is exactly the transcript in build/logs/t-boot.log:104-107 (2026-11-03
|
|
15:11), which is where the card's symptom comes from. Same three fsbn
|
|
numbers, same cp error: that run also had the medium read-only.
|
|
|
|
|
|
5. What to do with this
|
|
-----------------------
|
|
- Testing: attach an install image writable. A USB stick is a writable
|
|
medium; only a CD is not. `-drive ...,readonly=on` on a USB image tests a
|
|
configuration that does not exist in the field, and it fails for a reason
|
|
that has nothing to do with the image being good or bad.
|
|
- The tree: no patch. Upstream's install-image rc has assumed a writable
|
|
medium since it was written, the CD path already shows how a read-only
|
|
medium is handled (tmpfs union /etc + symlink), and this tree boots both
|
|
media. Making the install image read-only-safe would be a deviation, not a
|
|
bug fix; it belongs in a report, not in patches/src.
|
|
- If a read-only install image is ever wanted (PXE-style, an ISO-only host,
|
|
a write-protected stick), the change is the CD's two moves: symlink
|
|
/etc/gettytab to /tmp/gettytab when the rootfs is built
|
|
(installimage.mk, next to the etc.ttys/etc.rc copy) and mount a tmpfs with
|
|
`-o union` on /etc in installimage/etc.rc instead of `mount -u /`.
|
|
|
|
|
|
6. Correction to docs/reference/boot-cfg-timeout.txt section 9
|
|
--------------------------------------------------------------
|
|
That section says install-image "does not build in this tree", failing at
|
|
`mv work.rootfs imgroot.fs` after nbmakefs and nbinstallboot. That is wrong:
|
|
`build.sh ... install-image` completed on 2026-11-04 23:09 and produced both
|
|
NetBSD-11.99.9-amd64-install.img.gz (549299990 bytes, 23:06) and
|
|
NetBSD-11.99.9-amd64-bios-install.img.gz (549058608 bytes, 23:09)
|
|
(build/logs/t-f56c48f0-img.log, "Successful make install-image").
|
|
|
|
What those runs actually hit was a stale object directory: the EFI
|
|
install-image target builds in src/distrib/amd64/installimage itself (no
|
|
objdir), so a leftover work.fstab from an earlier run is taken as up to date
|
|
while the work/ tree it belongs to is not, and the recipe then fails at
|
|
`install -c -m 0644 work.fstab work/etc/fstab` with
|
|
"work.fstab: stat: No such file or directory" (same failure in
|
|
build/logs/op-img2.log:44-45). Starting from an empty build directory makes
|
|
it build. Finding, not fixed here: the EFI install-image target writes
|
|
2.6 GB imgroot.fs, 2.6 GB .img and 550 MB .img.gz into the pristine import
|
|
tree.
|