When a USB stick has been used for, say, a bootable Linux distribution, it usually cannot be re-used as a mass storage device by, say, Windows. These instructions are to wipe/reset a usb stick so it will work as it used to.
(This is largely untested)
See also:
on Windows ∞
How do you partition a USB Thumb / Flash Drive?
cmdas admindiskpart.exelist diskselect disk 1(or whatever)list partitionselect partition 1(or whatever)delete partitionordelete partition overridecreate partition primary-
create partition logical
not confirmed:
format fs=[format type] label="[label name]" quick
on Linux ∞
source: https://slint.fr/installers/Restore_an_USB_stick.txt
cat /proc/partitions dmesg | tail # you need to be root for that one
The device name is probably something like /dev/sdb or /dev/sdc, for these instructions it is /dev/sdx
(1) Wipe the bootsector of the USB stick:
drive=/dev/sdx \dd if=/dev/zero of="$drive" bs=512 count=1
(2) Create a new partition on the USB stick using fdisk or cfdisk.
Set the type "FAT32" for that partition.
TODO - fdisk can be automated, turning this whole set of instructions into one script.
(3) Write a FAT32 filesystem on it:
drive=/dev/sdx \mkdosfs -F32 "$drive"1
Last updated 2024-07-21 at 05:52:39

Added Windows partitioning notes