How to secure wipe USB drive, SD card on Ubuntu

We will look at both Graphical (GUI) and command-line methods of secure wiping the USB drive and SD card such that data can't be recovered by the professional recovery tools available out there. Make sure to bookmark the article for your future needs as you never know when you will be handing over a USB drive to your friend!

SD Cards and portable USB drives are among the many flash storage devices we have in the market today. SD Cards are commonly used in smartphones and cameras to hold personal data and digital information.

If you delete this data the usual way, it is possible to recover it using various data-recovery tools we have in the market today. Therefore, if you are working with sensitive information, you need to wipe it completely, such that it is difficult to recover.

Before looking at some of the ways to wipe data securely on SD cards and USB drives, we need to understand why it’s more complicated compared to ordinary hard drives.

Flash storage devices require a block/cell completely wiped out of any data before any other data is written on it. Having this in mind, the overall process of writing data to SD cards would be longer, were it not for new technology implemented on these devices.

Most of these flash storage drives have a 10-20% more on-board storage than the indicated capacity and a memory controller. When writing any data on a flash storage media, the memory controller will dynamically map all empty cells, and during low load, it will wipe the unmapped blocks/cells. This feature raises a security issue of possible data recovery.

Lack of a tool that can leverage the memory controller, your operating system has close to zero chances of addressing every single cell on these devices. A lot of manufacturers today are providing tools that you can use to wipe data securely on their devices. However, if your current vendor doesn’t have such a tool, this article will provide you with several workarounds.

Secure wiping the data in a USB drive or SD Card

We will look at both Graphical (GUI) and command-line methods. Our distro of choice is Ubuntu 19.04 (Disco Dingo); however, it should work with all other Ubuntu releases. Previously, we did an article on – How to Format a USB drive on Ubuntu using both graphical and command-line methods. Be sure to check it out.

Wipe the data completely using the Disks Manager

It is one of the most straightforward methods, even for Linux newbies. The Disks utility comes preinstalled in all Ubuntu releases; therefore, no need to run any installation (apt-get install …) commands.

Step 1). Insert your USB drive into any working port on your PC. Ensure it’s listed on the Ubuntu file manager.

USB Drive listed on the file manager
USB Drive listed on the file manager

Step 2). Launch the Disks utility.

Launch Disks utilty from applications menu
Launch Disks utility from the applications menu

Step 3). Select your USB drive or SD card.

Select the USB drive or SD Card you want to wipe data
Select the USB drive or SD Card you want to wipe data.

Step 4). To completely wipe data, we will use the usual format process only that we will introduce one more feature. Click on the Settings icon and select the format option. It is illustrated in the image below.


Step 5). A window will pop-up where you will be required to set the volume label and the file system type you want to use. One more option we are going to use here is the Erase button. Click on it and ensure it turns to green. Click Next to continue.

Set Volume name and turn on the erase button
Set Volume name and turn on the erase button

Step 6). A window will pop-up listing all the set options and a warning that all data on will be lost. Click the Format button to continue.

The Format warning screen
The Format warning screen

This process will take time than usual. It is also dependent on the size of the USB drive or SD Card.

Wipe data completely using the DBAN tool

One more graphical tool we can utilize to wipe data on a USB drive or SD card securely is the Darik’s Boot and Nuke (DBAN). It is a self-contained utility that completely wipes data on any storage device connected to the computer.

It is a Linux open-source tool that runs on a Live USB drive. You will, therefore, need to change the boot order of your laptop and use the bootable USB drive of DBAN. Download DBAN ISO image from the official website and burn it on a USB drive. You can check our article on the MultiBootUSB tool used to create a multi-boot USB drive.

Step 1). Boot your PC using a bootable USB drive of DBAN. You should see the DBAN welcome screen appear. Press Enter key to continue.

DBAN Boot screen
DBAN Boot screen

Step 2) Choose which storage device you want to wipe data. You can navigate using the UP and DOWN arrow keys and select using the Space Bar key. Press Enter to continue.

Select the Storage media you want to wipe.
Select the Storage media you want to wipe.

Step 3). Wait for DBAN to finish erasing the drive contents. You will see the general progress displayed in a percentage format. There is no pause or stop option on this screen. You, therefore, need to be careful when working with this tool.

DBAN Wiping Data process.
DBAN Wiping Data process.

Step 4). Once the process is completed, you will see the DBAN notification screen.

DBAN Process completed successfully
DBAN Process completed successfully

We have looked at two ways you can completely wipe data using graphical utilities. With everyday advancements in technology, we can’t say it will be impossible to recover the data, but it will be challenging. In case you are not contented with the above tools, lets now go the command-line way.

Wipe data using Terminal Commands

It is no surprise that most readers will skip directly to this section. The Terminal is one of the most potent utilities we have in Ubuntu or any other Linux distribution. There are two powerful commands that we will work with for this post, and luckily, all of them come preinstalled.

The DD command

It is one of the most common methods used to wipe data on Linux distributions securely. It is not a fast process and might take a while, depending on the size of the USB drive or SD card. The best way to use the DD command is to execute it overnight and leave your PC running. In the morning, when you wake up, everything should be set.

By running the dd –help command on the Terminal, you should be able to see all the features this tool has to offer.

dd --help command image
dd –help command image

Step 1). Insert the USB Drive or SD card that you want to wipe data. Ensure it is not mounted. Otherwise, unmount it using the file manager or the umount command.

sudo umount [device_label] -l
sudo umount /dev/sdb -l

In case you are not sure of your device label, execute the following command:

sudo fdisk -l

Step 2). Now let’s wipe all the data on our USB or SD card. Execute the command below.

sudo dd if=/dev/urandom of=/dev/devicename bs=10M
sudo dd if=/dev/urandom of=/dev/sdb bs 10M

You can execute this command severally to ensure more difficulty in any data-recovery attempts. Filling the drive with random data multiple times will cause the memory controller to remap the cells and eventually overwrite enough of them, making your device more secure and complicated to recover data.

The SHRED command

Another command-line option is using the SHRED command. One being advantage is that you can wipe particular files in the USB drive/SD card or the entire storage media. It comes preinstalled in most Linux distributions, including Ubuntu.

Execute the shred –help command and see what features this command has to offer.

Shred --help command
Shred –help command

Step 1) Shred command to wipe out particular files in a USB drive or SD card.

shred -u image1.png test.docx

The above command will wipe out three files at a go – image1.png and test.docx. Note, you have to change directory to the device you are wiping data.

Step 2). Shred command to wipe all data in an entire USB drive or SD card. Just like the dd command, shred also takes quite some time. 

sudo shred -vfz [device_label]
sudo shred -vfz /dev/sdb


Those are some of the methods you can use to securely wipe data on a USB drive or SD card using Ubuntu. In case your USB drive or SD card vendor has provided a utility to wipe data completely, then make an effort of using that too. If you find this article useful, don’t forget to share the link with friends.

Arun Kumar
Arun did his bachelor in computer engineering and loves enjoying his spare time writing for FOSS Linux. He uses Fedora as the daily driver and loves tinkering with interesting distros on VirtualBox. He works during the day and reads anything tech at night. Apart from blogging, he loves swimming and playing tennis.


Please enter your comment!
Please enter your name here




Getting Started with Linux Operating System

The Linux operating system brings forth a vibrant mix of features and security, making it the best alternative to macOS or Windows operating systems. In this post, we will give you a master guide on Getting started with Linux systems - taking you from a complete beginner to a level where you can begin testing the various Linux distributions available with much ease.

How to Create a Comprehensive Mail Server on Ubuntu

Postal is a free and open-source mail server used to send and receive emails. It comes loaded with tons of excellent features and functionalities, making it extremely popular among large organizations as well as in enterprise settings.

The 10 Best Linux Performance Monitoring Tools

Do you want to monitor the performance of your Linux system? Are you looking for some powerful performance monitoring tools to help you out? If you agree, it's your day as we have put together a detailed list of the ten best Linux performance monitoring tools.

How to Boot your Windows or Linux PC from a USB Drive

Sometime back, the process of installing an operating system required users to pop a bootable media disk into their DVD or CD drive and use it to boot the PC. But times have changed. Nowadays, the most common way of installing an OS is booting from a USB drive. The use of USB drives is further propelled by the current production of slim and lightweight laptops with no support for DVD/CD drives.

Python For Loop: Everything You Need to Know

Loops are one of the essential elements in any programming language, and Python is not an exception to it. Loops are used to repeat a statement or a block of statements multiple times. If there were no concept of loops in programming languages, we have to write each statement again and again for the number of times we want to execute it.

How to install LibreOffice on Fedora

If you are looking for a feature-rich and reliable Office Suite for your Fedora PC, then you have an excellent option at hand. LibreOffice, a free and opensource app, has stood the test of time and evolved into a beautiful alternative to Microsoft Office.


Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

Linux Mint vs. Ubuntu – which is best for you?

The conundrum is that which one among them? The best solution is to try both of them out, and then choose whatever seems to work the best for your needs. But here, we're giving you some distinctions between the both that might make it easier for you to make a choice.

Removing the Virus from a Windows PC with a Ubuntu Live USB drive

In this tutorial, we are going to show you how to clean your Windows machine from infected viruses using an Ubuntu live USB or CD and the ClamAV antivirus. The ClamAV is a free, open-source antivirus that can be used on Ubuntu.

10 ways to use the Chown command with examples

Any file in a Linux system belongs to a particular owner(s) and a group. It is one of the many features that maintain security in Linux systems. For example; If a file belongs to say UserA, then UserB cannot manipulate the data depending on any additional permissions set unless the user has permission to do that.