Permanently erasing a flash drive: Have you ever wondered how to permanently delete files from a USB drive so no one can recover them? In this tutorial, we show you how to wipe USB drives on Windows, macOS, and Linux, making sure that your files are gone for good.
Erasing a Flash Drive to Permanently Delete Files

Why Just Deleting Files from Drives Isn't Enough
When you delete a file from a USB drive, the file is not truly gone. Even after you empty your trash, the data is still there and can be recovered unless it gets overwritten with new information. This is why simply deleting files does not guarantee your privacy. The same is true of a quick format-it clears the filesystem's file table, but the actual file data typically remains on the drive until overwritten.
Wiping Free Space vs. Wiping the Entire Drive
Before picking a method, it helps to know which problem you're actually solving:
- Wiping free space overwrites only the empty/unallocated area of the drive-useful when you want to permanently erase previously deleted files while keeping the files you currently have.
- Wiping the entire drive overwrites everything, including the partition table and every existing file. This is the right choice before selling, donating, or disposing of a drive.
Jump to the section for your operating system: Windows | macOS | Linux
Warning: Data Loss is Permanent
Once you proceed with any of these methods, the data on your USB drive will be permanently lost. Ensure that you have backed up any important files before continuing, as this process is irreversible, especially if you perform multiple passes.
How to Wipe a USB Drive on Windows
Windows includes two free, built-in tools that cover both use cases-no extra software required.
Wipe Free Space on Windows (cipher)
The cipher command can overwrite the deleted/unused space on a drive while leaving your current files alone:
- Open Command Prompt (search for "cmd" in the Start menu).
- Note your USB drive's letter (e.g. E:) in File Explorer first.
- Run the following, replacing E: with your drive letter:
cipher /w:E:\
This makes three passes over the free space (zeros, then 0xFF, then random data) and can take a while on larger drives.
Wipe an Entire Drive on Windows (DiskPart)
Warning: This destroys everything on the drive, including the partition table. Triple-check the disk number before running clean all-DiskPart will not ask you to confirm again.
- Open Command Prompt and type
diskpart, then press Enter. - List all connected disks:
list disk - Identify your USB drive by its size, then select it (replace # with the correct disk number):
select disk # - Run a single-pass secure overwrite of the entire drive:
clean allUsing just
clean(without "all") only removes partition information and is much faster, but leaves the actual file data recoverable-for a true wipe, you needclean all. - Once complete, create a new partition and format it so the drive is usable again:
create partition primary format fs=exfat quick assign
Free GUI option: If you'd rather not use the command line, Eraser is a well-established, free, open-source Windows tool that can securely wipe files, folders, or entire drives through a simple interface.
How to Wipe a USB Drive on macOS
Using Disk Utility (GUI)
- Open Disk Utility (Applications > Utilities, or search with Spotlight).
- Select your USB drive in the sidebar (choose the drive itself, not just a partition under it).
- Click Erase in the toolbar.
- Choose a format (exFAT or FAT32 for cross-platform use with Windows and Linux).
- If a Security Options button is available, you can slide it toward more secure (multi-pass) erasure. Note that Apple no longer offers this multi-pass option for many SSD/flash-based drives, since, as covered above, overwrite passes are less meaningful on wear-leveled flash storage-a standard single erase plus the Terminal method below is generally the practical choice for USB flash drives.
Using Terminal (diskutil)
For more control, macOS's built-in diskutil command can wipe either just the free space or the entire drive:
- Open Terminal (Applications > Utilities).
- List your disks to find the correct identifier (e.g. disk4):
diskutil list - To wipe only the free space (keeping existing files), replacing disk4 with your drive's identifier:
diskutil secureErase freespace 1 disk4 - To securely erase the entire drive instead (destroys everything):
diskutil secureErase 1 disk4The number after
secureErasesets the method: 0 is a single zero-fill pass, 1 is a single random-data pass, while 2 (7-pass) and 3 (35-pass Gutmann) exist but are unnecessary on modern drives and can take an extremely long time.
How to Wipe Free Space on a USB Drive in Linux
To fill the free space on a USB drive with zeros-making previously deleted files nearly impossible to recover, while keeping your current files intact-we can use the dd command. Here's how:
- Open a terminal window: Press Ctrl + Alt + T to open the terminal.
- Find your USB drive: Type the following command to list all drives and find your USB device letter. Press Enter to run it:
sudo fdisk -l - Create a mount directory: We need a directory to mount the drive. Run:
sudo mkdir /tmp/ddusb - Mount your USB drive: Replace x and # with your USB drive's letter and partition number, then run this command:
sudo mount /dev/sdx# /tmp/ddusb - Zero out the empty space: Overwrite all empty space on the USB drive with zeros by running:
sudo dd if=/dev/zero of=/tmp/ddusb/junk.bin status=progressThis process may take some time. Wait until you see "no space left on device."
- Delete the junk file: Once the process is complete, remove the file that filled the space:
sudo rm /tmp/ddusb/junk.bin
Other Linux Methods for Wiping an Entire USB Drive
Besides using the dd command against free space, there are other powerful tools in Linux to securely wipe an entire USB drive-destroying everything on it, including the partition table. Two popular options are Shred and Wipe.
A Note on Flash Drives and Wear Leveling
Before using shred, dd, or wipe on an entire USB drive, it's worth understanding a real limitation of these tools on flash-based storage. Unlike traditional spinning hard drives, USB flash drives and SSDs use wear leveling: the drive's controller spreads writes across physical NAND cells and keeps some cells in reserve, remapping which physical cell corresponds to which logical address over time. A software overwrite pass only touches the logical addresses the operating system can see-it can't guarantee it reaches every physical cell that ever held your data, including cells the controller has marked as spare or worn out. GNU's own shred documentation explicitly warns about this limitation on solid-state and wear-leveled media.
In practice, this means overwrite-based wiping is still a reasonable, effective step for everyday privacy (deterring casual recovery attempts, wiping a drive before reuse or resale), but it isn't an absolute guarantee against a well-resourced forensic lab. If you need that level of assurance-for example, disposing of a drive that held highly sensitive data-consider whether your drive supports ATA Secure Erase (via hdparm --security-erase, on drives that support it) or, for drives being discarded entirely, physical destruction.
Securely Delete Files using Shred:
The shred command allows you to overwrite files or entire partitions with random data multiple times, making recovery much more difficult. Here's how you can use shred to wipe a USB drive:
- Find your USB drive: Start by identifying your USB device using the following command:
sudo fdisk -l - Use shred to wipe USB drives: To securely erase the entire USB drive with shred, you can run:
sudo shred -v -n 3 /dev/sdx- -v: Verbose mode, showing progress as the command runs.
- -n 3: Specifies the number of passes. In this case, it will overwrite the USB three times.
- /dev/sdx: Replace x with the correct letter for your USB drive (no partition number-this targets the whole device).
This process may take some time depending on the size of your USB drive.
Use Wipe to Erase a USB Drive:
The wipe command erases the contents of your USB drive by overwriting it with multiple secure passes. To install wipe and use it, follow these steps:
- Install wipe: If wipe is not installed on your system, you can install it using your package manager. Run the following command:
sudo apt install wipe - Use wipe to erase USB drives: Once installed, you can wipe your USB drive by running:
sudo wipe /dev/sdx- /dev/sdx: Replace x with the correct letter for your USB drive.
Wipe will securely erase the USB drive by making multiple passes, ensuring that the data is nearly impossible to recover.
How to Format Your USB Drive After Wiping (Linux)
After erasing a USB drive, you can reformat it to make it usable again. To format the USB drive with the ext4 file system, for example, you can run:
sudo mkfs.ext4 /dev/sdx#
Replace x and # with the correct device name.
Random Data vs. Zeros
Although overwriting with zeros is effective, using random data offers an extra layer of security. Forensic tools may still recover some patterns from zeroed out drives, while random data makes this much more difficult. To overwrite with random data, modify the dd command like this:
sudo dd if=/dev/urandom of=/tmp/ddusb/junk.bin status=progress
This method is slower but provides a higher level of data destruction.
How Many Passes Do You Actually Need?
Older data-destruction standards (like the 7-pass DoD 5220.22-M method or the 35-pass Gutmann method) were designed around the physical characteristics of older magnetic hard drives. Current guidance, including NIST Special Publication 800-88, treats a single well-verified overwrite pass as sufficient for modern storage media. Additional passes mainly add time rather than meaningfully more security-though as noted above, no number of software overwrite passes fully solves the wear-leveling limitation on flash drives specifically.
Best Practices for USB Drive File Security
To further protect your data, consider these best practices for USB flash drive file security:
- Encrypt your files: Before wiping, encrypt sensitive data with tools like gpg or LUKS to make sure it can't be read, even if recovered.
- Restore and Format the USB drive: After securely erasing a flash drive, restore the USB drive format to ensure it is clean and ready for reuse.
Frequently Asked Questions
Can deleted files be recovered from a USB drive?
Yes, in most cases. Deleting a file or emptying the trash only removes the reference to it in the file system-the actual data remains on the drive until it's overwritten, which is why dedicated wiping is necessary for sensitive files.
Does formatting a USB drive permanently erase it?
Not on its own. A standard "quick format" just recreates the file system's table of contents; the underlying file data is typically still recoverable until it's overwritten with a tool like dd, shred, or wipe.
Is dd or shred safe to run on a flash drive?
Yes, running these commands won't damage a modern flash drive beyond normal write wear. Just be certain you've selected the correct device letter first, since these commands will destroy data on whatever device you point them at.
Do I need multiple passes to securely wipe a drive?
For most purposes, no-a single overwrite pass is considered sufficient by current standards like NIST 800-88. Extra passes mainly cost time rather than adding meaningful additional security on modern media.
Will overwriting really stop forensic recovery on a USB flash drive?
It will stop virtually all casual and consumer-level recovery attempts. Due to wear leveling on flash storage, it can't offer an absolute 100% guarantee against a well-equipped forensic lab. For drives holding highly sensitive data that you're disposing of entirely, ATA Secure Erase or physical destruction are more definitive options.
How do I wipe a USB drive on Windows without installing anything?
Use the built-in tools: cipher /w: wipes free space only, while diskpart with clean all wipes the entire drive. Both come with Windows already.
How do I wipe a USB flash drive on a Mac?
Use Disk Utility's Erase function for a standard erase, or the Terminal's diskutil secureErase command for a scriptable single-pass (or multi-pass) overwrite of the whole drive, or diskutil secureErase freespace to wipe only the free space.
Does this process work the same for SD cards?
Yes-SD cards use flash memory with wear leveling as well, so the same commands, methods, and caveats in this guide apply to them.
Troubleshooting Common Issues
- Permission denied errors? Make sure you are using sudo with administrative privileges for all commands.
- "Device or resource busy" when mounting or wiping? Unmount the drive first with
sudo umount /dev/sdx#, and make sure no file manager or other program has it open.
Final Thoughts and Data Recovery
That's all it takes to wipe USB flash drives! Whether you filled the free space with zeros or wiped the entire device with shred or wipe, you've made deleted files extremely hard to recover through normal means.
Note: Overwriting a USB drive with zeros or random data is a widely accepted method for data destruction. However, as covered above, wear leveling on flash-based drives means advanced forensic tools might still be able to recover fragments of deleted data in rare cases. For the highest level of assurance on especially sensitive data, pair software wiping with encryption beforehand, or consider ATA Secure Erase or physical destruction.