I have been running an RPi3b+ for more than a year doing mostly ./build.sh ; the 'system' remained on the SD card, but a USB HD held the source. About a month ago, I couldn't log in to my account! Figuring I was hacked, went to console, root login worked.
Fishing around more, /usr/pkg/bin/zsh was gone! W T F?
Using Occam, I figured corrupt SD card. I replaced it, all is fine. Yet....
Is there a preferred way to determine which sectors are bad on the old SD card? Plugged in a USB-to-SDcard adaptor with the presumed bad uSD:
Jul 3 04:11:55 S /netbsd: [ 370462.5581262] umass2: using SCSI over Bulk-Only
Jul 3 04:11:55 S /netbsd: [ 370462.5581262] scsibus2 at umass2: 2 targets, 1 lun per target
Jul 3 04:11:55 S /netbsd: [ 370462.5781259] sd2 at scsibus2 target 0 lun 0: <Generic-, USB3.0 CRW -SD, 1.00> disk removable
Jul 3 04:11:56 S /netbsd: [ 370463.6182434] sd2: fabricating a geometry
Jul 3 04:11:56 S /netbsd: [ 370463.6182434] sd2: 30528 MB, 30528 cyl, 64 head, 32 sec, 512 bytes/sect x 62521344 sectors
Jul 3 10:09:54 S /netbsd: [ 370463.6382510] sd2: fabricating a geometry
Then ran this:
# nice dd if=/dev/rsd2 of=/dev/null
62521344+0 records in
62521344+0 records out
32010928128 bytes transferred in 30505.600 secs (1049345 bytes/sec)
#
No errors were reported in /var/log/messages
So now I'm wondering: was I hacked? Or is dd not the best way to test for bad sectors? Or, has the SD card somehow re-mapped the bad sectors? Or?