Re: disk non-destructive bad-block write/fix?

From: grarpamp <grarpamp_at_gmail.com>
Date: Tue, 20 Sep 2022 05:45:55 UTC
> throwing a lot of errors

USB... reseat cables.

> Is there a way to exercise the free blocks on a ufs disk and move all
> defective ones to the bad-block list?

That's function of the hw, not the fs.

If you want to nuke the fs and do that to the disk
dd if=/dev/urandom of=/dev/da0 bs=1m

If not, then you can pray to hit most of the fs data areas with
dd if=/dev/urandom of=/mnt/bigrandfile bs=1m

but that's a prayer.

Better to buy enough media to have backups of backups.

> Or is that already happening in the above scenario?

Yes most firmwares modepages are set to automatically
write-reallocate, you can fiddle those using the scsi/ata/usb
spec and camcontrol.

Store a sha256 of all the files,
read them back to verify and compare to that.

> The disk is about 40% full

There's probably not a shrinkfs, and without checking where those
existing extents are, attempting to create a tailing 60% fs to
move the 40% into to write-realloc it... could end up footshot.

> wondering if the whole rest of it is trashed

dd if=/dev/da0 of=/dev/null bs=1m conv=noerror

But that's only a read test, not a write test.