Skip to content

Instantly share code, notes, and snippets.

@dagar
Last active November 23, 2021 10:41
Show Gist options
  • Save dagar/8d002760ee1f8e76d1bd88c16a469d24 to your computer and use it in GitHub Desktop.
Save dagar/8d002760ee1f8e76d1bd88c16a469d24 to your computer and use it in GitHub Desktop.
linux_sdcard_test_and_format.sh
#! /bin/bash
# assumes /dev/sdb is sd card
# make sure it's not mounted
sudo udisksctl unmount --block-device /dev/sdb
sudo time badblocks -svw -t random /dev/sdb
sudo time f3probe --destructive --time-ops /dev/sdb
sudo parted --script /dev/sdb mklabel msdos
sudo parted --script /dev/sdb mkpart primary fat32 1MiB 100%
sudo time mkfs.vfat -c -v /dev/sdb1
sudo parted /dev/sdb --script print
sudo time fsck.vfat -a -t -v -V /dev/sdb1
sudo udisksctl power-off --block-device /dev/sdb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment