Monday, August 18, 2014

Simplified USB Wiping Via Linux Command-Line

Method taken from: [ http://www.pendrivelinux.com/restoring-your-usb-key-partition/ ]

They have a universal live USB-stick program that works in windows very easy and consistent (which means there's code bloat that you don't need, but it's OK to get to simpler OS's)

1. Note any drives you have plugged in.
2. Plug in stick and note drive letter (sdx) x being some letter.
3. Open terminal and type "fdisk -l", that's a lowercase "L".
4. Type "fdisk /dev/sdx" (replace x w/ drive letter, don't add the number if there is one)
5. Type "d" to delete partition.
6. Type "1" to select 1st partition (and go thru typing "d" and deleting all partitions)
7. Type "n" to make new partition.
8. Type "p" to make partition primary.
9. Type "1" to make it first partition.
10. Press "enter" to accept default first cylinder. If there's a virus in those 2000+ blocks, you can't solve that yet if you're doing this. Start somewhere, practice, research, learn, and kill the malware eventually; but not yet. Press "enter" again to accept default last cylinder.
11. Type "w" to write new partition to USB-stick.
12. Type "umount /dev/sdx1" (again replace 'x' w/ drive letter).
13. Type "mkfs.vfat -F 32 /dev/sdx1" (again replace the 'x'). Had a little hiccup on my end when messing around, doing "mkfs.vfat -t /dev/sdx1" got me back to reading the USB stick again for unknown reasons.

You can load the drive w/ whatever massive file[s] and then delete again if it makes you feel better. If you're up to it, try to learn the actual (likely C) code and corresponding Assembly code (you can keep going deeper if you want) and find compilers/assemblers you trust or make one yourself if you're truly badass.


/***** NOTE *****/

It may help to use the "Format" utility in the OS first too.  But this procedure works pretty good, just not 100% as there's still all sorts of weird things that can happen and this uses less code than downloading another program to do everything for you automatically (and not doing a full wipe perhaps).

No comments: