Erasing a Flash Drive - Permanently Delete Files

Erasing a flash drive; How do I permanently delete files from a USB drive, forever? Is it possible to erase or clear data from a USB drive to make deleted information unrecoverable? These are all great questions and yes can be accomplished fairly quickly and easily from within Linux. Follow along to learn how to wipe a USB drive.

Erasing a USB Flash Drive | Permanently Delete files

erasing flash drive
When you delete a file from a drive, the file is not completely erased, even after emptying your trash or recycle bin. Until the space a file once occupied is overwritten with new information, that deleted file is still recoverable. Making it possible for you or anyone to potentially recover files you thought were permanently deleted. The same holds true when you delete files from a USB flash drive; though files deleted from a USB device do not go to the trash or recycle bin, the deleted information can still be recovered until that space is overwritten with new information.

The following tutorial explains how to permanently remove deleted information from your USB flash drive or any other partition. This makes the deleted files or information (for the most part) non-recoverable. We are able to accomplish this task by zeroing out the empty space on the drive using dd. There are many great uses for dd, from forensic data recovery and data backup to zeroing out empty drive space.

How to Delete a USB Drive | Erasing a Flash Drive

Erasing a flash drive or how to delete a USB drive. Removing all files in an effort to make data unrecoverable.

The following flash drive erasure procedure assumes you are up and running from Linux with your USB drive inserted and ready to use. You will be wiping and clearing data from your USB drive by zeroing out the empty space (filling it with zeros). This essentially makes the information you permanently deleted from your USB drive, not recoverable.

To proceed to permanently erase data from a USB drive;

  1. First, open a terminal window. Ctrl+Alt+T
  2. Now, from the terminal, you can use the fdisk command to locate the drive letter and partition for your USB device. To do this, type or copy and paste the following and press Enter:
    sudo fdisk -l

    (make a note of which device and partition you would like to zero out)

  3. Next, create a directory to be used to mount your device partition:
    sudo mkdir /tmp/ddusb
  4. Then, to mount your partition to this directory
    (replacing x# with your device and partition):

    sudo mount -o loop /dev/sdx# /tmp/ddsdb
  5. Next, overwrite the empty space on the drive with zeros:
    sudo dd if=/dev/zero of=/tmp/ddusb/junk.bin status=progress

    This process will take some time as every byte is being written. Once finished, dd will report that there is "no space left on device". This is normal.

  6. Finally, you'll want to remove the zero filled file that currently occupies the empty space. To remove the bin file so that you can free up the empty space for use:
    sudo rm /tmp/ddusb/junk.bin

That's all there is to it. Now all of the remaining empty space on this partition has been filled with zeros through the junk.bin file. Any deleted information (files, folders, pictures, videos, notes, etc) that were once on your USB flash drive, and later trashed or recycled, have essentially been overwritten. Rendering those files very hard to recover.

This concludes one way to use Linux for erasing a flash drive in an attempt to permanently delete files. Helping you delete a USB drive and make those trashed files unrecoverable or very hard to recover.

Important Note: Though recovered information would likely be corrupted; it may still be possible to recover deleted data using data recovery measures found in some very sophisticated forensic tools, as the data was only overwritten once with zeros. To make the file clearing and deletion process more secure, you could make multiple passes on the drive.