Add a Linux version for PCs that won't boot Windows #5

Open
aporter wants to merge 3 commits from linux-quick into main
Owner

Adds linux/inventory.py, a quick Linux version of the v1 inventory for PCs whose Windows won't boot (PC-002 first). Boot any live Linux USB (Ubuntu "Try Ubuntu", or Ventoy) and run sudo python3 <stick>/inventory/inventory-linux.py.

What it does

  • Same asset-ID banner, tester questions, result folder (pending/<ID>_<time>/ with report.md, report.json, summary.md, title.txt, private.txt) and machines.csv as i.ps1. A PC keeps one ID whichever script runs.
  • Same fingerprint rules as v1. Tested against v1's own Get-HwFingerprint in pwsh: identical for both Dell tags and for the MAC fallback.
  • Checks what Linux can see: CPU, RAM modules, SMART health/wear/errors, sequential read speed, GPU and driver, monitors, NICs, Wi-Fi, internet, hardware clock, audio, optical, Bluetooth, webcam, battery, TPM, Secure Boot, BitLocker, Win 11 readiness, and kernel-log disk/hardware errors since boot.
  • Windows version, activation, event log and Device Manager are reported as SKIP. The report says it came from a Linux run.
  • No upload: results wait in pending/.

Never writes to the PC

  • Every internal disk and partition is set read-only with blockdev --setro (and verified) before anything is mounted. NTFS is only mounted ro, under tmpfs.
  • Every write goes through guard(): the resolved target must be on a disk identified as USB/removable, or on tmpfs. Symlink and mount escapes are refused, and a failed lsblk disables disk output.
  • A disk the live system already uses read-write is left alone and listed under "Safety notes".
  • smartmontools is installed into the live session only when every internal disk is verified read-only.

Testing

  • py_compile, parser fixtures (dmidecode, lspci, EDID, smartctl JSON including open-failed and no-SMART), the write guard on a mocked mount layout, and a machines.csv round trip with pwsh Import-Csv/Export-Csv.
  • Not yet run on real hardware. PC-002 will be the first run.
  • workbench validate fails in workbench's own ensure-test.sh link tests (unrelated to this repo). gitleaks' only hit is the existing token in i.ps1.

Review-gate: gpt-6.1-sol fix-then-ship, fixed and rechecked

  • Plan review: fingerprint normalisation, block-level read-only, no upload, and no false PASS were all built in.
  • Diff review, 5 blocking items, all fixed: verified tmpfs instead of "major 0", lsblk failure fails closed, guard() on every resolved write, SMART needs real health evidence, and empty DMI memory is WARN.
  • Recheck, 2 blocking items, fixed: mount folders guarded, and smartctl install requires all disks locked. Small fix, not re-reviewed.

🤖 Generated with Claude Code

Adds `linux/inventory.py`, a quick Linux version of the v1 inventory for PCs whose Windows won't boot (PC-002 first). Boot any live Linux USB (Ubuntu "Try Ubuntu", or Ventoy) and run `sudo python3 <stick>/inventory/inventory-linux.py`. ## What it does - Same asset-ID banner, tester questions, result folder (`pending/<ID>_<time>/` with report.md, report.json, summary.md, title.txt, private.txt) and `machines.csv` as `i.ps1`. A PC keeps one ID whichever script runs. - Same fingerprint rules as v1. Tested against v1's own `Get-HwFingerprint` in pwsh: identical for both Dell tags and for the MAC fallback. - Checks what Linux can see: CPU, RAM modules, SMART health/wear/errors, sequential read speed, GPU and driver, monitors, NICs, Wi-Fi, internet, hardware clock, audio, optical, Bluetooth, webcam, battery, TPM, Secure Boot, BitLocker, Win 11 readiness, and kernel-log disk/hardware errors since boot. - Windows version, activation, event log and Device Manager are reported as SKIP. The report says it came from a Linux run. - No upload: results wait in `pending/`. ## Never writes to the PC - Every internal disk and partition is set read-only with `blockdev --setro` (and verified) before anything is mounted. NTFS is only mounted `ro`, under tmpfs. - Every write goes through `guard()`: the resolved target must be on a disk identified as USB/removable, or on tmpfs. Symlink and mount escapes are refused, and a failed `lsblk` disables disk output. - A disk the live system already uses read-write is left alone and listed under "Safety notes". - smartmontools is installed into the live session only when every internal disk is verified read-only. ## Testing - `py_compile`, parser fixtures (dmidecode, lspci, EDID, smartctl JSON including open-failed and no-SMART), the write guard on a mocked mount layout, and a `machines.csv` round trip with pwsh `Import-Csv`/`Export-Csv`. - **Not yet run on real hardware.** PC-002 will be the first run. - `workbench validate` fails in workbench's own `ensure-test.sh` link tests (unrelated to this repo). gitleaks' only hit is the existing token in `i.ps1`. Review-gate: gpt-6.1-sol fix-then-ship, fixed and rechecked - Plan review: fingerprint normalisation, block-level read-only, no upload, and no false PASS were all built in. - Diff review, 5 blocking items, all fixed: verified tmpfs instead of "major 0", lsblk failure fails closed, `guard()` on every resolved write, SMART needs real health evidence, and empty DMI memory is WARN. - Recheck, 2 blocking items, fixed: mount folders guarded, and smartctl install requires all disks locked. Small fix, not re-reviewed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
linux/inventory.py runs the v1 inventory from a live Linux USB. It writes
the same pending/<ID>_<time> folder and machines.csv as i.ps1 and uses the
same fingerprint rules, so a PC keeps its asset ID whichever script runs.

Internal disks are set read-only with blockdev --setro before anything is
mounted, NTFS is only mounted read-only, and results are never saved to an
internal disk. Windows-only checks are reported as SKIP. It does not upload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every write now resolves its real target and must land on a disk identified
as USB/removable or on tmpfs; a failed lsblk disables disk output. SMART
without health evidence and empty DMI memory data are no longer PASS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'linux-quick:linux-quick'
git switch 'linux-quick'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'linux-quick'
git switch 'linux-quick'
git rebase 'main'
git switch 'main'
git merge --ff-only 'linux-quick'
git switch 'linux-quick'
git rebase 'main'
git switch 'main'
git merge --no-ff 'linux-quick'
git switch 'main'
git merge --squash 'linux-quick'
git switch 'main'
git merge --ff-only 'linux-quick'
git switch 'main'
git merge 'linux-quick'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
aporter/inventory!5
No description provided.