Partition and format any USB device using exFAT filesystem. https://forum.manjaro.org/t/11763
Find a file
2024-01-03 11:08:17 +01:00
format-usb.sh Add format-usb.sh 2024-01-03 11:06:05 +01:00
LICENSE Initial commit 2024-01-03 10:40:28 +01:00
README.md Update README.md 2024-01-03 11:08:17 +01:00

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]