format-usb.sh | ||
LICENSE | ||
README.md |
utility-format-usb.sh
Description
The scripts partitions and formats any USB device using exFAT filesystem. To avoid accidental format of non removable devices a couple of safeguards exist.
The script will check if the supplied device is valid then it checks if the device is in fact a removable device. If any of these checks fail the script aborts.
The script will ask for user confirmation twice and default to abort on Enter
Use case
Re-purpose the USB stick if you have flashed an ISO to it.
Why? Because writing an ISO using dd
writes an ISO9660 filesystem to a small part of the USB - the rest is inaccessible.
Instructions
Create the folder ~/.local/bin and copy the file format-usb.sh
into the folder, then make sure the file is executable.
mkdir -p ~/.local/bin
chmod +x ~/.local/bin/format-usb.sh
Usage
Remove your USB if attached and list devices
lsblk
Insert your USB device and list the devices
lsblk
The new device in the list is your USB device e.g. /dev/sdy - format the device using the script
format-usb.sh /dev/sdy
Note
What this script does can probably be done in numerous ways with numerous tools.
The list contains validation is taken from this [stackoverflow topic][1]