How to Permanently Delete All of the Information on Your USB Drive or SD Card Using Linux

We independently review everything we recommend. When you buy through our links, we may earn a commission.

Delete Information USB Drive Linux

Learn how to safely delete data on Linux so that the information on your USB drive or SD card may never be recovered by an unauthorized party.

These days, USB drives and SD cards are commonplace pieces of technology used in everyday life. However, the fact that they are so widely used makes them a potential threat. Because these devices frequently include people’s sensitive information, you need to clear all of the data off of them before handing them off to another individual. In addition, before discarding any storage devices, it is important to delete any data that may be stored on them.

Linux comes with a variety of tools that make it simple to delete personal information. In the following, we will take a look at some of the several methods in which you may safely delete data from your USB drive or SD card when using Linux.

Formatting vs. Erasing: What’s the Difference?

We are aware that formatting a USB renders inaccessible any and all data stored on the device. However, does it totally delete any previously stored data? The correct response is “no.” Simply because the act of formatting your device entails nothing more than the creation of a new partition, which in turn renders the previous partitions readable. However, the data in its original form is still stored on the device.

The availability of several reliable data recovery solutions has made the process of extracting data from such devices a piece of cake. Therefore, if your drive contains any sensitive data, you shouldn’t merely format the device; rather, you should concentrate on wiping the data from the disk. Overwriting your USB drive or SD card with unneeded random data is required in order to successfully delete any information stored on either device.

Secure Wipe Flash Drive or SD Card Contents in Linux

You’ll need to go through a few steps in order to delete all of your personal information from the device you’re using. Finding the right apparatus is the first thing that has to be done. To determine which device and partition are in question, run the lsblk command.


It will provide a list of all the block devices that are currently connected to the system. Find your device using the amount of storage space it has. For the purpose of this example, we’ll think of /dev/sdb as the device, and /dev/sdb1 as the primary partition on that device. Unmount the partition using the following command once you’ve found the device and the partition you want to work with:

sudo umount /dev/sdb1

After the device has been unmounted, you will need to overwrite the data that is stored on it. Users of Linux have access to a variety of utilities, such as dd, shred, and badblocks, among others. When you have finished erasing the data, you will need to create a new partition on your USB drive and format it using Linux.

Erase USB Drive or SD Card Using dd

Erase USB Drive SD Card dd

In Linux, the dd command is utilized for purposes like file copying and conversion. On the other hand, dd is another option for erasing everything that is stored on a device for data storage.

The following dd command, for instance, will replace the data on your USB device or SD card with all zeroes. Make sure that the right device name is used, or else you might end up deleting additional partitions.

sudo dd if=/dev/zero of=/dev/sdb bs=4096 status=progress

A straightforward overwrite with zeros is sufficient for most users’ needs. However, depending on the circumstances, it may be possible to retrieve some of the lost data by making use of specialist software. If you are worried about this, you should overwrite your disk with random data rather than with just zeroes.

sudo dd if=/dev/urandom of=/dev/sdb bs=4096 status=progress

Depending on the size of the device, the completion of this instruction might take a significant amount of time. After it is finished, a prompt that says “No space left on device” will appear on your screen. Now, all that is left for you to do is create a new partition utilizing the file system of your choice.

Secure Wipe USB Drive or SD Card Using shred

The shred utility is a comprehensive data erasure application that is standard fare for all Linux versions. Because it is included in the coreutils package, it is an excellent option for removing private information from storage media such as USB or SD cards.

It is a strong program that can replace storage with data that seems to be pseudo-random. Therefore, the likelihood of restoring previously deleted material is quite low. When left to its default settings, shred will erase data using three separate passes. However, you have control over this parameter through the use of the -n option.

sudo shred -v /dev/sdb

When the -v option is used with shred, it instructs the program to show a progress report on the process. When the -z option is used, a final overwrite is performed, but this time it uses only zeroes. This is useful for concealing the effects of shredding.

sudo shred -v -z /dev/sdb

In addition to that, shred enables the overwriting of devices with data derived from random sources, such as /dev/urandom.

sudo shred -v -z –random-source=/dev/urandom -n1 /dev/sdb

Erase USB Drive or SD Card Using badblocks

A destructive read-write test that makes use of badblocks enables you to wipe the contents of your flash drive in a safe and secure manner. It is a piece of software that can locate damaged portions of storage devices. The fact that badblocks is pre-installed on the majority of popular Linux distributions is one of the many advantages offered by this program.

To completely remove everything from /dev/sdb, use the badblocks command that is provided below. Because it writes the data in four different passes, this operation may take a significant amount of time.

sudo badblocks -wsv /dev/sdb

The -s and -v options have been integrated in order to display a progress bar while also receiving comprehensive information. If you’d like a more streamlined method, you can use the command that follows instead:

sudo badblocks -wsv -t 0x00 /dev/sdb

The -t option allows one to provide a test pattern that will be written over. The preceding command does a single pass of all zeroes, which is why it is comparable to the speed of other commands.

Create New Partition on Your USB Drive or SD Card

When you use one of the techniques described above to replace storage, the process will delete everything, including any partitions and the partition table. Before you can utilize the device, you will first need to make a new partition and then format the new disk. Using fdisk in Linux makes it simple to create and manage disk partitions on a computer.

sudo fdisk -l

This command will list all of the partitions on your system, including those on any external storage devices, such as an SD card or USB drive. To pick your device (/dev/sdb), use the command that is shown below. Take care with this step, and make sure that everything is checked twice.

sudo fdisk /dev/sdb

You will be prompted to type the fdisk command. Now create a new partition by pressing the n key. In order to create this partition, you will need to select a partition type, number, as well as the beginning and ending positions of the storage sector. It is recommended that you maintain everything in its original state by pressing the Enter key.

You will need to write the modifications to your device when you have finished creating the partition. In fdisk, type the w command, and then press the Enter key. It will create the new partition known as /dev/sdb1 when it is finished. After it is finished, format the partition by using the command that is listed below:

sudo mkfs.vfat -F 32 /dev/sdb1

Safeguard Personal Data From Falling Into the Wrong Hands

With the continuous advancement of technology and all that it has to offer, data has taken on an increasingly more significant role. Consequently, the protection of one’s personal information ought to be of the utmost importance to everyone. Therefore, before giving your USB devices and SD cards to other people or selling them, you need to be sure that they have been thoroughly erased.

It is also extremely necessary to remove data from old mobile phones in a way that cannot be recovered since ancient mobile phones are also quite easy to retrieve data from.

We will be happy to hear your thoughts

Leave a reply