If you're automating this under OS-X, the following might be useful.
First, Find the disk you care about using diskutil list
:
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *3.9 GB disk1
1: DOS_FAT_32 UNTITLED 3.9 GB disk1s1
Note the IDENTIFIER
column; the shorter one (in this case, disk1
is the whole disk; the longer ones e.g. disk1s1
are volumes on that disk).
Pass the name of the disk you want to wipe to this script:
#!/bin/bash
disk=$1
if [ -z "$disk" ]; then
echo I need you to give a disk to wipe, e.g. disk1
exit 1
fi
diskpath=/dev/$disk
diskutil unmountDisk $diskpath
if [ "$2" == "secure" ]; then
echo Wipe of disk requested before format...
diskutil zeroDisk $diskpath
fi
echo Partitioning...
diskutil partitionDisk $diskpath 1 MBRFormat FAT32 UNTITLED 100%
diskutil list $diskpath
diskutil mountDisk $diskpath
This will re-partition the disk to have one large FAT32 volume on an MBR-partitioned disk; if you pass "secure" as well, it'll zero-wipe the disk for added security.
Examples:
./wipedisk.sh disk1
will make disk1 have one partition (disk1s1) formatted FAT32
./wipedisk.sh disk2 secure
will zero disk2 and then create a FAT32 partition (disk2s1)