#!/usr/bin/env bash # # archboot-restore-usbstick.sh - restore usbstick to FAT32 # by Tobias Powalowski # usage(exitvalue) # outputs a usage message and exits with value APPNAME=$(basename "${0}") usage() { echo "Restoring an USB device to its original state (FAT32):" echo "usage: ${APPNAME} " exit "$1" } ################################################## [[ -z "${1}" ]] && usage "$@" ### check for root if ! [[ ${UID} -eq 0 ]]; then echo "ERROR: Please run as root user!" exit 1 fi # clean partitiontable dd if=/dev/zero of= bs=512 count=2048 wipefs -a "$1" # create new MBR and partition on fdisk "$1" < mkfs.vfat -F32 "$1"1