Skip to content

scripts: add full-drive test helper for macOS - #284

Open
sbrunner-atx wants to merge 1 commit into
AltraMayor:masterfrom
sbrunner-atx:macos-test-script
Open

scripts: add full-drive test helper for macOS#284
sbrunner-atx wants to merge 1 commit into
AltraMayor:masterfrom
sbrunner-atx:macos-test-script

Conversation

@sbrunner-atx

Copy link
Copy Markdown

What

Adds scripts/f3-drive-test-macos.sh: a helper that runs a complete erase / f3write / f3read verification cycle on macOS, in the spirit of the existing log-f3wr script but handling the macOS-specific pitfalls.

Why

Running f3write/f3read by hand on macOS has several traps this script closes:

  • diskutil disk numbers are assigned by connection order, so when testing several drives it is easy to erase the wrong one, or to attribute a log to the wrong physical drive. The script requires a user-chosen drive label, records it together with the USB location ID and device serial number, and asks for confirmation naming that label before erasing. It also refuses internal disks and partition slices outright.
  • Reading back immediately after writing measures the page cache, not the drive. The script unmounts and remounts between the passes.
  • Some failing drives only show their defect under repeated or thermally loaded reads. The script supports --reads N consecutive passes and a --cooldown / --replug pause between write and read, so failure time can be compared across passes.

It needs only f3write/f3read (from PATH or a sibling build/ directory), so it works with the stock macOS build and is independent of #283.

Origin

This came out of diagnosing a batch of refurbished 128 GB drives: one unit wrote all 114 GB cleanly but could not sustain more than about 90 seconds of sequential reading before disconnecting from the bus, with time-to-failure shrinking on consecutive passes (about 100 s cold down to about 9 s warm) - a clear thermal signature that a single default write/read pass does not isolate.

Disclosure: developed with AI assistance; reviewed and field-tested by the author on real hardware.

f3-drive-test-macos.sh drives a complete erase / f3write / f3read cycle
on macOS with diskutil, adding what ad-hoc use of the tools tends to
get wrong:

- refuses to run on internal disks or partition slices, and asks for
  explicit confirmation naming the drive label before erasing
- records the USB location ID and device serial number next to a
  user-chosen drive label, so logs stay attached to the physical drive
  even though macOS reassigns diskN numbers by connection order
- unmounts and remounts between write and read so f3read measures the
  drive instead of the page cache
- optional cooldown (--cooldown SEC, or --replug for a physical
  unplug) between write and read, and repeated read passes (--reads N),
  for diagnosing drives that drop off the bus under sustained I/O,
  e.g. from overheating: compare failure time across back-to-back
  passes
- per-drive timestamped logs and a summary table of all read passes

Only needs f3write/f3read (PATH or ../build), so it works on macOS with
the stock tools, independent of the extra-tools port in AltraMayor#283.

This grew out of diagnosing a batch of refurbished 128 GB drives where
one unit passed a full 114 GB write but could not sustain more than
about 90 seconds of reading before disconnecting - a failure mode that
a single write/read pass with default settings does not isolate.
@sbrunner-atx

Copy link
Copy Markdown
Author

Field report from the first production use of this script: I tested a 5-pack of refurbished SanDisk Ultra 128 GB drives from eBay. Two of the five failed in the same way - the full 114 GB write completes fine, then the drive disconnects 37-60 seconds into the read-back ("Device not configured").

The repeated read passes (--reads) turned out to be the key: time-to-failure shrinks from about 100 s cold to about 9 s warm across back-to-back passes - a thermal signature that a single write/read pass does not isolate. The good drives throttle their read speed to ~77 MB/s and run forever; the defective ones read at 144-160 MB/s, never throttle, and cook themself into a bus dropout.

The descriptor logging also earned its place: the two defective units are a different hardware revision, identifiable without any test - media name "Ultra" with serial prefix 0401, while all good drives report "SanDisk 3.2Gen1" with prefix 0901. The correlation held on every drive checked.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant