Skip to content

os: the installed appliance is a persistent OS, not the live RAM image (#712) - #1291

Merged
bong-water-water-bong merged 2 commits into
mainfrom
1bit/os712-full-install
Nov 6, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
1bit/os712-full-install

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

#712, rescoped: the installer puts a persistent 1bit OS on the disk, not the live RAM image

Owner, 2026-11-06: "puppy and we will offer install packages for distros" — Puppy is the one base, the installer
installs it to disk, other distributions are our install packages. This PR is the installer half; the boot entry of the
same step is #709 (pi-os3) and step 7 of 1bit-install.sh is untouched.

What was wrong, measured on the shipped bytes

1bit-install copies the booted stick's /data partition (which is also where /1bit lives) onto the new disk. That
is right for the frugal install — kernel, initrd, four SFS — but the shipped medium carries no save layer, and
every GRUB entry asks for pfix=copy:

$ sudo mount -o ro,loop,offset=$((1050624*512)) ~/wt/puppy-out-c31/1bit-os-puppy.img /mnt/c31
$ ls /mnt/c31/1bit
bdrv_upup64r_26.04.sfs  fdrv_…sfs  initrd.gz  puppy_…sfs  vmlinuz  zdrv_…sfs      # no upup64rsave*
$ grep -c 'pfix=copy' /mnt/esp/EFI/BOOT/grub.cfg
4

So the "installed" machine was the live image with a bigger disk under it: PUPMODE=5 (the session is thrown away at
power-off) and ~1.4 GB of SFS copied into RAM on every boot. That is exactly the owner's sentence: a full persistent
install rather than the live RAM image
.

The fix — two things, both written at install time

  1. the save layer /1bit/<DISTRO_FILE_PREFIX>save is created on the target. It is a save folder, which is
    Puppy's own write-through root: the init finds it by prefix (find_save_file) and setup_psave makes
    <folder>/upper the overlay's upperdir, so PUPMODE=12 and every write lands on the disk as it is made. Its name
    comes from the image's own /etc/DISTRO_SPECS and the installer refuses to start without it — a guessed name
    installs cleanly and then boots with no persistence at all. Puppy's own creator does the same two things
    (shutdownconfig: mkdir + .DirIcon); a layer with no /initrd/DISTRO_SPECS is a normal first boot
    (rc.update's rc_update_force_pm5 pass rebuilds /etc from the SFS). A SAVESPEC copied from an installed
    source is removed — it names that machine's partition.
  2. pfix=nocopy in place of pfix=copy in the copied grub.cfg, so the installed system mounts its SFS from its
    own disk instead of RAM-copying them every boot. The stick keeps pfix=copy: it is a live medium and that is its
    point. Read-back fails the install if a linux line still carries pfix=copy or none carries pfix=nocopy.

shortcut: the installed disk is treated as a hard disk (pmedia=usbhd → PUPMODE=12, direct writes); an install
onto a bare flash stick gets direct writes instead of Puppy's flash-friendly PUPMODE=13. Upgrade (read the removable
flag, write pmedia=usbflash) if installing to flash sticks becomes a target.

The gate — the installed disk's own boots, not the installer's log line

install-probe.sh (QEMU, Secure Boot on, 1bit-install /dev/vda onto a second disk) now also boots the installed disk
by itself, then again into its serial root shell, and asserts the two things on the running system. Candidate: c31's
shipped SFS + only usr/local/bin/1bit-install (~/wt/puppy-out-i712/1bit-os-puppy.img, d0b5cfe7…, SFS
92c89f84…), run as PUPPY_PUPSFS=uuid PUPPY_ASSERT_PUPSFS=1 … install-probe.sh <img> <work> 1500:

INFO grub.cfg      linux /1bit/vmlinuz … psubdir=1bit … pfix=nocopy,nox console=ttyS0,115200 console=tty0
PASS grub.cfg      pupsfs=UUID=82abada3-… (and 1bit.data= stays on the UUID)
PASS installed     the installed disk reached userspace on its own boot line
INFO persist       PUPMODE=12 | root layer=/initrd/mnt/dev_save/1bit/upup64rsave/upper | save layer=/data/1bit/upup64rsave
INFO persist       SFS mounted from: /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3
INFO persist       backed by: /dev/loop1: [2050]:262148 /initrd/mnt/dev_save/1bit/fdrv_upup64r_26.04.sfs
INFO persist       /data room: /dev/sda2 7.4G 1.3G 5.7G 19% /data
PASS persist       PUPMODE=12, root writes through /initrd/mnt/dev_save/1bit/upup64rsave/upper, SFS from /dev/loop0 …
PASS persist       /root/712-persist still there after a reboot, PUPMODE=12 on both boots
== PASS

Three failed runs before it, and what each one caught: attempt 1 was the box at load average 80 (the 180 s wait for the
GRUB menu expired — that is the harness, not the candidate, and it needs no change); attempt 2 passed PUPSFS= where
the script reads PUPPY_PUPSFS= so the pre-existing #865 row failed before my legs ran; attempt 3 exposed two defects
in my own rows — boot-time service notices interleave on the serial console (a row read
24onboard-webapp: serving … as its answer, so every value now comes through its own TOKEN= prefix and a __S__
bracket), and printf "%%s,\" reached awk literally because the command line is an argument of a %-format, so
the SFS row printed %s,%s,%s,%s, and its /mnt/tmpfs assertion was vacuously true. Both are fixed; the losetup -a
row is the loop backing files that prove where the SFS come from.

The installer's new refusals are exercised off-device too: with the two sed expressions applied to the stick's own
four linux lines, linux … pfix=copy, → 0 matches and pfix=nocopy → 3, and a comment line that mentions
pfix=copy does not trip the refusal (the check is line-scoped to linux lines).

Not in this PR, deliberately

Files

file change
os/v3/puppy/1bit-install.sh pre-flight save name from /etc/DISTRO_SPECS; save layer created in step 4; pfix=nocopy + assertions in step 5; read-back in step 6; header comment and the final say
os/v3/puppy/install-probe.sh the installed disk's own boots: an Installed class (bracketed rows, guest reboot -f on the same VM) and the persistence verdicts
docs/os-v3.md the rescope (no Ubuntu autoinstall, install-any-distro for other distributions) + a new "The installed machine is a persistent OS (#712)" section; the Ubuntu design is retitled history
docs/os-v3-live-puppy-eval.md the recommendation is marked decided and the fallback withdrawn
os/v3/puppy/README.md the rescope in the intro, and the 1bit-install.sh row describes the save layer and pfix=nocopy

refs #712. Closes nothing on its own: the issue keeps the user/update half, named above.

#712)

`1bit-install` copied the live stick's state to the disk, and the stick has no save
layer on purpose (it writes to RAM) and boots with `pfix=copy` on every entry (the
SFS are copied into RAM). So an "installed" 1bit OS was the live image with a bigger
disk under it: PUPMODE=5, nothing persists across a reboot.

Two changes, both written at install time rather than left to a first boot:

* the save layer `/1bit/<DISTRO_FILE_PREFIX>save` is created on the target. Its name
  comes from the image's own /etc/DISTRO_SPECS (Puppy's init finds a save folder by
  that prefix) and the installer refuses to start without it - a guessed name installs
  cleanly and then boots with no persistence. A `SAVESPEC` copied from an installed
  source is removed (it names the other machine's partition).
* the copied grub.cfg gets `pfix=nocopy` in place of `pfix=copy`, so the installed
  system mounts its SFS from its own disk instead of RAM-copying ~1.4 GB every boot.
  The stick keeps pfix=copy: it is a live medium.

`install-probe.sh` gains the installed disk's own boots and asserts both on the disk:
PUPMODE=12, the root's upperdir under the save folder, no squashfs mount from
/mnt/tmpfs, and a write to /root that survives the guest's own reboot.

refs #712 (the boot-entry half of the same install step is #709, pi-os3).
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1291 ready for review at 768b956

@bong-water-water-bong
bong-water-water-bong merged commit 700f561 into main Nov 6, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/os712-full-install branch November 6, 2026 20:26
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

712 - Partially compliant

Compliant requirements:

  • The installed appliance is a full operating system, not the live RAM image
  • The installer puts a persistent 1bit OS on the disk
  • The save layer is created on the target disk
  • The copied grub.cfg stops asking for pfix=copy

Non-compliant requirements:

  • The installed machine must be a full persistent OS and not the live RAM image (this is partially covered by the install-probe.sh logic, but not fully implemented in the core installer)

Requires further human verification:

  • The installed machine must be a full persistent OS and not the live RAM image (requires manual verification of the boot process and persistence checks)

709 - Partially compliant

Compliant requirements:

  • The installer registers a firmware boot entry
  • The firmware boot entry points to the target disk's ESP
  • The firmware boot entry is put first in BootOrder
  • The firmware boot entry is set as BootNext for the first reboot
  • The installer removes stale entries
  • The resulting BootOrder is printed on screen
  • The installer reboots itself after printing the boot order

Non-compliant requirements:

  • None

Requires further human verification:

  • None

865 - Partially compliant

Compliant requirements:

  • The installer step 5 no longer rewrites pupsfs=1BIT-DATA inside comments

Non-compliant requirements:

  • The init must resolve UUID=... in pupsfs (this is not addressed in the PR, but the PR fixes the installer to use UUID=... which should be sufficient)

Requires further human verification:

  • The init must resolve UUID=... in pupsfs (requires manual verification of the init behavior)
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Save Layer Creation

The PR introduces creation of a save layer on the target disk, which is a key part of making the installed machine a persistent OS. However, the logic for determining the save layer name relies on parsing /etc/DISTRO_SPECS which may not be robust if the file format changes or is malformed.

prefix=$(sed -n "s/^DISTRO_FILE_PREFIX='\([^']*\)'/\1/p" /etc/DISTRO_SPECS 2> /dev/null | head -1)
[ -n "$prefix" ] || die "no DISTRO_FILE_PREFIX in /etc/DISTRO_SPECS: the save layer's name (what the init looks for) cannot be derived"
save_name=${prefix}save
Grub.cfg Modification

The PR modifies the grub.cfg to change pfix=copy to pfix=nocopy. This is correct for making the installed system mount SFS from the disk instead of copying into RAM, but the verification logic in install-probe.sh should also ensure that the change was applied correctly to all relevant entries.

-e "s|pfix=copy|pfix=nocopy|g" \
Persistence Verification

The new persistence verification logic in install-probe.sh is comprehensive but relies on several assumptions about the system state and output format. If any of these assumptions are incorrect, the verification may fail even when the system is functioning correctly.

print("== the installed disk, its own boots: is it a persistent OS? (#712)")
v = Installed("persist", shell=True)
try:
    if v.s is None:
        ok = False
    else:
        def val(token, cmdline, timeout=240):
            """the value behind `TOKEN=` in the command's output (last match). Every row prints its value
            with its own prefix, because the console is shared with the running system's notices."""
            out = v.cmd("echo %s=$(%s)" % (token, cmdline), timeout) or ""
            m = re.findall(r"\b%s=(.*)" % token, out)
            return (m[-1].strip() if m else "")

        pm = val("PM", "sed -n 's/^PUPMODE=//p' /etc/rc.d/PUPSTATE | head -1")
        rw = val("RW", "readlink /initrd/pup_rw")
        lay = val("LAY", "ls -d /data/1bit/*save* 2>/dev/null | head -1")
        # NOTE: one `%s`, not the escaped form - the cmdline is an ARGUMENT to val()'s "%s=$(%s)" formatting,
        # so a `%%` here reaches awk literally and the row prints "%s,%s,%s,%s," while asserting nothing
        # (measured on the previous run: it "passed" because that string cannot contain /mnt/tmpfs).
        sfs = val("SFS", "awk '$3 == \"squashfs\" { printf \"%s \", $1 }' /proc/mounts")
        room = val("ROOM", "df -h /data | tail -1")
        loop = val("LOOP", "losetup -a 2>/dev/null | head -1")
        print("INFO persist      PUPMODE=%s | root layer=%s | save layer=%s" % (pm, rw, lay))
        print("INFO persist      SFS mounted from: %s" % sfs[:200])
        print("INFO persist      backed by: %s" % loop[:200])
        print("INFO persist      /data room: %s" % room[:120])
        if pm != "12":
            print("FAIL persist      PUPMODE=%s, not 12: the installed machine boots the live RAM image "
                  "(no save layer, nothing persists)" % (pm or "<unread>")); ok = False
        elif "/1bit/" not in rw or not rw.endswith("save/upper"):
            print("FAIL persist      the root's writable layer is %s, not a save folder on the disk" % (rw or "<none>")); ok = False
        elif "/mnt/tmpfs" in sfs:
            print("FAIL persist      the SFS are copied into RAM (pfix=copy): %s" % sfs); ok = False
        elif not sfs:
            print("FAIL persist      no squashfs mount at all: cannot say where the OS came from"); ok = False
        else:
            print("PASS persist      PUPMODE=12, root writes through %s, SFS from %s" % (rw, sfs.strip()))
        wrote = val("WROTE", "sh -c 'echo 712 > /root/712-persist; sync; cat /root/712-persist'")
        if wrote != "712":
            print("FAIL persist      could not write to the installed root (/root/712-persist: %s)" % (wrote or "<no answer>")); ok = False
            v.close()
        elif not v.reboot():
            print("FAIL persist      the installed disk did not come back after its own reboot (transcript %s)" % (v.path + ".log")); ok = False
            v.close()
        else:
            back = val("BACK", "cat /root/712-persist")
            pm2 = val("PM", "sed -n 's/^PUPMODE=//p' /etc/rc.d/PUPSTATE | head -1")
            if back == "712" and pm2 == "12":
                print("PASS persist      /root/712-persist still there after a reboot, PUPMODE=12 on both boots")
            else:
                print("FAIL persist      after a reboot /root/712-persist=%s, PUPMODE=%s "
                      "(the installed machine lost the write)" % (back or "<gone>", pm2 or "<unread>"))
                ok = False
finally:
    v.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant