Test and format SD cards

I wrote a short bash script that tests SD cards with F3 to see if they’re fake, deletes everything on them, creates a new partition table and one exFAT partition on them.

Here it is:

#!/usr/bin/env bash set -euox pipefail sudo umount --force "$1"1 || true sudo f3probe --destructive --time-ops "$1" sudo parted --script "$1" "mklabel msdos" "mkpart primary ext4 0% 100%" sleep 1 sudo mkfs.exfat -n Stavros "$1"1 eject "$1"

Save it as formatsd.sh and run it as ./formatsd.sh /dev/sdX.


Last updated on August 18, 2021. For any questions/feedback, email me at hi@stavros.io.