Corrupted microSD cards

The Raspberry Pi I ordered last month suddenly stopped booting today.

I tried re-imaging the microSD a couple times but was still having the same issue. Doing some tests, it seems the SD card is corrupting data, the data written and data read back doesn't match.

Ratchet :: Desktop/ubuntu-img/20.04 1 » sudo diskutil umountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
Ratchet :: Desktop/ubuntu-img/20.04 » dd if=ubuntu-20.04.3-preinstalled-server-arm64+raspi.img | pv | sudo dd of=/dev/rdisk2 bs=1m
6578718+0 records in5MiB/s] [     <=>                                                                                          ]
6578718+0 records out
3368303616 bytes transferred in 97.391697 secs (34585121 bytes/sec)
3.14GiB 0:01:37 [33.0MiB/s] [   <=>                                                                                            ]
0+51412 records in
0+51412 records out
3368303616 bytes transferred in 97.361365 secs (34595896 bytes/sec)
Ratchet :: Desktop/ubuntu-img/20.04 » sudo head -c 3368303616 /dev/rdisk2 > read
Ratchet :: Desktop/ubuntu-img/20.04 » md5 ubuntu-20.04.3-preinstalled-server-arm64+raspi.img
MD5 (ubuntu-20.04.3-preinstalled-server-arm64+raspi.img) = d553686673d8326a9b8b64ce3d677d6d
Ratchet :: Desktop/ubuntu-img/20.04 » md5 read
MD5 (read) = 115bbe351f5012dfd1a7fbfa6dc6fbc2

In fact it turns out data wasn't being written at all.

Ratchet :: Desktop/ubuntu-img/20.04 » sudo dd if=/dev/zero of=/dev/rdisk2 bs=1g count=1
1+0 records in
1+0 records out
1073741824 bytes transferred in 28.385853 secs (37826653 bytes/sec)
Ratchet :: Desktop/ubuntu-img/20.04 1 » sudo head -c 1073741824 /dev/rdisk2 > read
Ratchet :: Desktop/ubuntu-img/20.04 » xxd -p read | grep -v 0 | head -c 1
3%  

After doing some googling, SD card controllers will put the card into read-only mode to prevent further data loss if it detects that too many bad blocks have been written. So I guess the SanDisk Extreme Pro has died. Just a month after (light) use – the RPI was idle for the most part of the month.