Sean's Musings as a Service

Sean's Musings as a Service

Securely cleanup your pen drives

  • Published:
  • categories: linux
  • tags: sdelete, thumbdrive

While solid state storage is not subject to the same risks as a magnetic platter, it is useful to take some precautions to avoid file recovery if you transfer customer and company confidential data on a regular basis on these little guys.

#!/bin/sh

mydiskname=$1
mydevname=$2

umount /media/${mydiskname}
time shred -f -n 2 ${mydevname}

parted ${mydevname} mkpart primary fat32 1 1015

Here is an example run.

sgw@sobek:/media$ sudo umount /media/disk
[sudo] password for sgw:
sgw@sobek:/media$ sudo fdisk -l /dev/sde
Disk /dev/sde: 2063 MB, 2063597568 bytes
64 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 3968 * 512 = 2031616 bytes
Disk identifier: 0x69f96b49
Disk /dev/sde doesn't contain a valid partition table
sgw@sobek:/media$ sudo time shred -vf -n 2 /dev/sde
shred: /dev/sde: pass 1/2 (random)...
... <LOTS MORE LINES OF OUTPUT>
shred: /dev/sde: pass 2/2 (random)...2.0GiB/2.0GiB 100%
1.77user 609.37system 33:26.58elapsed 30%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+24182784outputs (0major+283minor)pagefaults 0swaps
sgw@sobek:/media$    
Reference: